Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autofill Destination

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Autofill Destination

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Autofill Destination

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autofill Destination

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Autofill Destination

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Autofill Destination

Thanx Norman

I really appreciate all your help.


Kind Regard

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep Destination Format SteveT Excel Discussion (Misc queries) 2 October 24th 07 03:42 PM
Destination Cell Steak77 Excel Discussion (Misc queries) 0 July 28th 06 06:24 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
How do I autofill combo boxes with their destination cell? Defoes Right Boot Excel Worksheet Functions 3 January 10th 05 12:49 PM
Help with "Autofill" Destination Range Joe MacPherson Excel Programming 0 May 6th 04 06:03 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"