Autofill Destination

P

poppy

Hi

I am trying to fill a number of cells with months up to the curren
month without having to hardcode the months. My problem is in the re
line. I would appreciate all your help.


Code
-------------------
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
lastrow = lastrow + 3

For i = 2 To 2
For j = lastrow To lastrow
With Cells((j), (i))
.FormulaR1C1 = "Jan"
Cells(j, i).Select
Selection.AutoFill Destination:=Range("B14:H14"), Type:=xlFillDefault
End With
Next
Nex
 
N

Norman Jones

Hi Poppy,

Try changing:

Selection.AutoFill Destination:=Range("B14:H14"),
Type:=xlFillDefault
To

.AutoFill Destination:=Selection.Resize(12), Type:=xlFillDefault

Note the initial period.
 
N

Norman Jones

Hi Poppy,

To add, it is rarely necessary to make a selection, so this portion of your
code:

could be written as:

With Cells((j), (i))
.FormulaR1C1 = "Jan"
.AutoFill Destination:=.Resize(12), Type:=xlFillDefault
End With
 
P

poppy

Hi Norman

The code works fine except for one small detail. It fills down. How d
I make it go in the other direction. In other words fill across rathe
downwards.


Thanx

Kind Regard
 
Top