Row Count and Save as... in a macro

F

freightliner2006

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
 
G

Guest

(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
 
F

freightliner2006

(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!
 
F

freightliner2006

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top