View Single Post
  #8   Report Post  
gerry405 gerry405 is offline
Junior Member
 
Posts: 11
Default

Dave,

Thanks, that now works a treat, now that I understand whats going on with that part of the code...


Quote:
Originally Posted by Dave Peterson
I'm guessing that this:
what does "d2:d2 stand for
was a typo

and you really meant:
what does "d2:d" stand for

It's easier to see with this:

Range("d2:d" & LastRow)

If the lastrow was 12345 (just for talking purposes), then

you'd get: Range("d2:d" & 12345)
or
Range("d2:d12345")
Which is column D rows 2:12345.

So I'm betting you really meant something like:

Range("F2").AutoFill _
Destination:=.Range("F2:F" & LastRow)

Range("L2").AutoFill _
Destination:=.Range("L2:L" & LastRow)

You start in L2 and finish with the last cell in column L
(lastrow=lastusedrow in column A)



gerry405 wrote:

thanks Dave,

I have tried the populating code as you suggested, it works fine for
one column(only), but I can't adjust it to do more than one column,
partly because I don't understand what your code is doing, more so at
the part below

ie

Range("D2").AutoFill _
Destination:=.Range("d2:d" & LastRow)
what does "d2:d2 stand for

When I run my macro I would like to populate more than one column so
I've tried to adjust to no avail, I thought I could do the following
with your code:

Option Explicit
Sub testme02()

Dim LastRow As Long
Dim wks As Worksheet

Set wks = ActiveSheet
With wks
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

Range("D2").AutoFill _
Destination:=.Range("d2:d" & LastRow)

Range("F2").AutoFill _
Destination:=.Range("d2:d" & LastRow)

Range("L2").AutoFill _
Destination:=.Range("d2:d" & LastRow)

End With

End Sub

But this does not work, I expect you'll know why, but to me it's double
dutch

--
gerry405


--

Dave Peterson