my first macro - super simple for any veteran... helpappreciated!
So copy.pasted the code, and I am getting -- Runtime error '1004':
Method 'Autofill' of object 'Range' failed.
Here's the code:
lr = Cells(Rows.Count, "g").End(xlUp).Row
Range("G2").AutoFill Destination:=Range("G2:G" & lr)
Range("G2:G" & lr).Select
Am I incorrect in assuming I can just insert this into the existing
Sub Macro() as ooposed to creating a new one just for this? I also
tried FSt1's version which looked pretty similar with the addition of
the "Dim lr As Long" and get the same... any ideas of what I am
doing wrong or leaving out?
Re-
On Feb 2, 10:12 pm, wrote:
Awesome, Don, Thanks.
On Feb 2, 10:02 pm, "Don Guillett" wrote: sub fillitup()
lr=cells(rows.count,"g").end(xlup).row
Range("G2").AutoFill Destination:=Range("G2:G" & lr)
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message
...
Since I dont have ANY experience programming (yet), I am limited to
creating macros by only recording them.
So, I recorded my first Macro, everything works great! But it only
works perfectly on the sheet I created it with and not on any other of
the same type, as intended. The issue is simple, the recorded macro
inserted a fixed range as shown he
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G289")
Range("G2:G289").Select
I simply must be able to replace the specified 'G289' in this case
with a variable associated to the row count in the Column G. I have
tried Help File, Googling for a while and just plain trying to learn
VBA programming on my own... but I have lost patience and am hoping
for a veteran to just tell me how to do it so I can get it done
finally!
Thanks in advance,
mtupper
VBA Rookie (future VBA junkie)
|