Small macro problem

  • Thread starter Thread starter Robert Gillard
  • Start date Start date
R

Robert Gillard

Dim rng As Range
Set rng = Range("g17").End(xlDown).Resize(1, 1)

rng.AutoFill Destination:=rng.Resize(rng.Columns.Count, 2)


What I want the above to do, is to go to the last item in Column G (say
G5) and copy it to the cell below (G6), but this fills both G6 and H7.

I feel sure it is very easy to resolve but I seem to have tried all
permutations without success.

Please advise where I am going wrong.


Bob
 
Switch your Row/Column values in .Resize():

Dim rng As Range
Set rng = Range("G17").End(xlDown)
rng.AutoFill Destination:=rng.Resize(2, 1)

Your code as written should have filled H5, not G6 and H7, right?
 
Hi Bob,

Try this:

Dim rng As Range
Dim rngLast As Range

Set rng = wks.Range("G1")
Set rngLast = Cells(Rows.Count, rng.Column).End(xlUp)

rngLast.Offset(1, 0).Value = rngLast.Value

I hope this helps.

Regards,
James S
 
Back
Top