Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic range in VBA Excel

Status
Not open for further replies.

drluggo

Programmer
Jan 14, 2003
39
US
When I use the following code:

Range("K1","K500").Select
Selection.Formula = sFormula

I have no problem. However, my application does not know where the data is going to end (i.e. the 500 will be variable) so I changed to this. Note that the data is in column A and the formula that acts on the data needs to go in column K:

sLastCell = "K" & Cstr(Range("A65536").End(xlUp).Row)
Range("K1",sLastCell).Select
Selection.Formula = sFormula

I get the following error when running this code:

"Method 'Range' of object '_Global' failed"

Does anybody know why this would be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top