Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

Row Count and Save as... in a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
freightliner2006@hotmail.com - 14 Nov 2007 19:26 GMT
Hi all,

1) A macro works on a worksheet with a variable number of rows R.
In column A, cell A2 is filled with some text. I need all cells from
A3 to A(R) to be filled the same.

2) The macro is stored in a book and works on another one. At the end,
I need the "object" book to be Saved As.... with a different name. So
I did:

ActiveWorkbook.SaveAs Filename:="MYNEWFILE.xls", FileFormat:=xlNormal

For some reason I don't know, the file is saved under \My Documents,
instead the "working" folder (meaning the directory where both books
are).

thanks for help
Barb Reinhardt - 14 Nov 2007 19:43 GMT
(1)  Range("A3:A" & R ).value = range("A3").value

The value of R may need to change depending on how you've defined it.

(2)
ActiveWorkbook.SaveAs Filename:=ActivewWorkbook.Path & "\" &
"MYNEWFILE.xls", FileFormat:=xlNormal
Signature

HTH,
Barb Reinhardt

> Hi all,
>
[quoted text clipped - 13 lines]
>
> thanks for help
freightliner2006@hotmail.com - 14 Nov 2007 20:08 GMT
On Nov 14, 2:43 pm, Barb Reinhardt
<BarbReinha...@discussions.microsoft.com> wrote:

> (1)  Range("A3:A" & R ).value = range("A3").value
>
> The value of R may need to change depending on how you've defined it.

Actually I don't know R "a priori", I need a function that tells me
the highest rownumber.

> (2)
> ActiveWorkbook.SaveAs Filename:=ActivewWorkbook.Path & "\" &
> "MYNEWFILE.xls", FileFormat:=xlNormal

Thanks a lot, this one works great!
freightliner2006@hotmail.com - 14 Nov 2007 20:56 GMT
On Nov 14, 3:08 pm, freightliner2...@hotmail.com wrote:
> On Nov 14, 2:43 pm, Barb Reinhardt
>
[quoted text clipped - 5 lines]
> Actually I don't know R "a priori", I need a function that tells me
> the highest rownumber.

never mind I got it with
R = ActiveSheet.UsedRange.Rows.Count

thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.