vba-excel-training - autofill excel using ranges
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » vba-excel-training - Autofill in Excel using ranges defined by variables

vba-excel-training - Autofill in Excel using ranges defined by variables

The UK's most regular instructor-led training courses.
Training information: vba-excel-training · Excel-courses-london · VBA courses London UK

resolvedResolved · Low Priority · Version Standard

Autofill in Excel using ranges defined by variables

Jane has attended:
Excel VBA course

by - delegate Jane [3 posts] (2007 Oct 11 Thu, 09:20) replyReply

I'm trying to get the last column to autofill across in order for the month headers to be updated correctly. I have the row number and column number parsed ito variables. This is the basic code, but I can't get it to accept the ranges defined by the variables (only seems to work if the range is hard-coded).

Cells(RowCount, ColumnCount).Select
Selection.AutoFill Destination:=Range(Cells(RowCount, ColumnCount), Cells(RowCount, ColumnCount + 1)), Type:=xlFillMonths

Any help please?
thanks,
Jane

Excel Advanced 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003 2008 Dec 3 Wed Bloomsbury 0 FULL    
2003 2008 Dec 5 Fri Bayswater 1 book now £195 £205
2002/XP 2008 Dec 10 Wed Tooting 0 FULL    
2003 2008 Dec 10 Wed Bloomsbury 0 FULL    
2007 2008 Dec 10 Wed Bloomsbury 2 book now £240 £245
2003 2008 Dec 12 Fri Southwark 5 book now £219 £235
Full Schedule: See all 96 Excel Advanced course dates.
Bookings currently available until 24th November 2009.

RE: Autofill in Excel using ranges defined by variables

by - trainer Carlos gold contributer[479 posts] (2007 Oct 24 Wed, 10:31) replyReply

Hi Jane

The xlFillMonths only works if the month is written in the first cell of the autofill. The system needs to know on which month to start.

I reset your code below and it did the autifill perfectly. Note the last ColumnCount is + 11 so as to Autofill 12 cells.

Cells(RowCount, ColumnCount).Value = "January"

Selection.AutoFill Destination:=Range(Cells(RowCount, ColumnCount), Cells(RowCount, ColumnCount + 11)), Type:=xlFillMonths


Hope this helps

Carlos

RE: Autofill in Excel using ranges defined by variables

by - delegate Jane [3 posts] (2007 Oct 24 Wed, 10:41) replyReply

Hi Carlos,

Thanks for that, but the month was already in the first cell of the autofill area as 01/09/2007. It appears to be the second row that the debugger is getting stuck on, not the first.

Cheers,
Jane

RE: Autofill in Excel using ranges defined by variables

by - trainer Carlos gold contributer[479 posts] (2007 Oct 24 Wed, 10:52) replyReply

Jane

I just tested the code I gave you with the date 01/09/2007 and it gave me a Autofill of 12 monthly dates to 01/08/2008

I entered the date in "A1". Then ran the following code:

Cells(RowCount, ColumnCount).Select

Selection.AutoFill Destination:=Range(Cells(RowCount, ColumnCount), Cells(RowCount, ColumnCount + 11)), Type:=xlFillMonths


Carlos

RE: Autofill in Excel using ranges defined by variables

by - delegate Jane [3 posts] (2007 Oct 24 Wed, 11:10) replyReply

Thanks Carlos, that's identical to the code I originally posted up, so the problem must actually be elsewhere, maybe where I'm finding the values to store in the variables. I'll check through the rest of my code some more.

Cheers,
Jane

RE: Autofill in Excel using ranges defined by variables

by - trainer Carlos gold contributer[479 posts] (2007 Oct 24 Wed, 12:32) replyReply

Jane

Hope you find where the problem is occurring.

Carlos


Related articles

· How to Create Better Excel Spreadsheets: Part One
· Microsoft Office and the Small Business: Part 1 Excel
· Compare Different MS Excel Training Methods
· Improve Performance Of Your Excel Macros
· 3 Reasons Why Excel Training Courses For Employees Can Improve Your Business

Excel tip:

Moving between split pane sections in a spreadsheet

If you have used the split panes feature in your worksheet, use the following keyboard shortcut keys to move quickly and effortlessly between paned sections:

F6 - Move to the next pane
Shift + F6 - Move to the previous pane

View all Excel hints and tips

Rate this page:
4.0/5 (3 votes cast)
Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information

Training Articles

AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz