Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Autofill dynamic no. of rows and columns

Hi,

I'm trying to copy the formulas from the first row starting from B2 to
some finite column number and applying these formulas (which may be
different) to a dynamic number of rows. In other words, the "BK6" is
not a fixed value. How can I achieve this? Thanks!


Range("B2").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.AutoFill Destination:=Range("B2:BK6"), _Type:=xlFillDefault

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Autofill dynamic no. of rows and columns

Do you want this final row to be user specified?

Dim iLastCol As Long
Dim iLastRow As Long

iLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
iLastRow = InputBox("specify last row #")
Range("B2", Cells(2, iLastCol)).AutoFill _
Destination:=Range("B2", Cells(iLastRow, iLastCol)),
Type:=xlFillDefault


--
HTH

Bob Phillips

wrote in message
ps.com...
Hi,

I'm trying to copy the formulas from the first row starting from B2 to
some finite column number and applying these formulas (which may be
different) to a dynamic number of rows. In other words, the "BK6" is
not a fixed value. How can I achieve this? Thanks!


Range("B2").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.AutoFill Destination:=Range("B2:BK6"), _Type:=xlFillDefault



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Autofill dynamic no. of rows and columns

Nope. It should be determined through a count of the first column's
number of rows. Will try out your suggestion. Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Autofill dynamic no. of rows and columns

Okay, then use this

Dim iLastCol As Long
Dim iLastRow As Long

iLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
iLastRow = Cells(Rows.Count,"B").End(xlUp).Row
Range("B2", Cells(2, iLastCol)).AutoFill _
Destination:=Range("B2", Cells(iLastRow, iLastCol)), _
Type:=xlFillDefault

--
HTH

Bob Phillips

wrote in message
oups.com...
Nope. It should be determined through a count of the first column's
number of rows. Will try out your suggestion. Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Autofill dynamic no. of rows and columns

Thanks Bob, works like a charm.

Yeh Wei



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
Autofill counting up Columns and Rows! fantomet Excel Worksheet Functions 5 December 14th 06 12:57 PM
Autofill Macro for 2 rows and 100 columns [email protected] Excel Programming 2 October 4th 05 02:37 PM
Autofill Macro for 2 rows and 100 columns [email protected] Excel Programming 0 October 4th 05 01:01 PM
autofill information from rows to columns without using transpose Rayce Excel Discussion (Misc queries) 1 September 4th 05 01:44 AM
Autofill formula to last row with data when rows will be dynamic A Waller[_2_] Excel Programming 3 June 20th 05 03:06 PM


All times are GMT +1. The time now is 01:05 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"