Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ------------------- Kind regard -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Poppy,
Try changing: Selection.AutoFill Destination:=Range("B14:H14"), Type:=xlFillDefault To .AutoFill Destination:=Selection.Resize(12), Type:=xlFillDefault Note the initial period. --- Regards, Norman "poppy " wrote in message ... Hi I am trying to fill a number of cells with months up to the current month without having to hardcode the months. My problem is in the red 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 Next -------------------- Kind regards --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Poppy,
To add, it is rarely necessary to make a selection, so this portion of your code: With Cells((j), (i)) .FormulaR1C1 = "Jan" Cells(j, i).Select Selection.AutoFill Destination:=Range("B14:H14"), Type:=xlFillDefault End With could be written as: With Cells((j), (i)) .FormulaR1C1 = "Jan" .AutoFill Destination:=.Resize(12), Type:=xlFillDefault End With --- Regards, Norman |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Message posted from http://www.ExcelForum.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Poppy,
Replace: Resize(12) with Resize(,12) --- Regards, Norman "poppy " wrote in message ... Hi Norman The code works fine except for one small detail. It fills down. How do I make it go in the other direction. In other words fill across rather downwards. Thanx Kind Regards --- Message posted from http://www.ExcelForum.com/ |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanx Norman
I really appreciate all your help. Kind Regard -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Keep Destination Format | Excel Discussion (Misc queries) | |||
Destination Cell | Excel Discussion (Misc queries) | |||
Autofill: Need to autofill one week block, (5) weekday only into cells. | Excel Discussion (Misc queries) | |||
How do I autofill combo boxes with their destination cell? | Excel Worksheet Functions | |||
Help with "Autofill" Destination Range | Excel Programming |