Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Want a macro for multiple columns on current macro for column

I am currently using the following macro in many of my worksheets and love
the time it saves. It's for one column. My question is, can this be
modified to do 2 or more columns?

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & endRow)

I have formulas in A2 and B2 and want to autofill at the same time instead
of separately. I tried modifying (Range("A2:B2"),etc.) but can't get it to
work.

Any help would be greatly appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Want a macro for multiple columns on current macro for column

The best I can see, the code you posted won't work for your original set up
because it is searching for the endRow in the same column you want to
AutoFill. Assuming that the 1 in the endRow calculation is actually some
other column (I'll use 3 for this example), then you can do this to
accomplish what you want...

Dim endRow As Long
endRow = Cells(Rows.Count, 3).End(xlUp).Row
Range("A2:B2").AutoFill Destination:=Range("A2:B" & endRow)

Notice column designation after the colon has been changed to B in BOTH
Range function calls.

--
Rick (MVP - Excel)


"Valerie" wrote in message
...
I am currently using the following macro in many of my worksheets and love
the time it saves. It's for one column. My question is, can this be
modified to do 2 or more columns?

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & endRow)

I have formulas in A2 and B2 and want to autofill at the same time instead
of separately. I tried modifying (Range("A2:B2"),etc.) but can't get it to
work.

Any help would be greatly appreciated!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Want a macro for multiple columns on current macro for column

How about:

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:B" & endRow)



"Valerie" wrote:

I am currently using the following macro in many of my worksheets and love
the time it saves. It's for one column. My question is, can this be
modified to do 2 or more columns?

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & endRow)

I have formulas in A2 and B2 and want to autofill at the same time instead
of separately. I tried modifying (Range("A2:B2"),etc.) but can't get it to
work.

Any help would be greatly appreciated!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Want a macro for multiple columns on current macro for column

It only works one column at a time.

"Valerie" wrote:

I am currently using the following macro in many of my worksheets and love
the time it saves. It's for one column. My question is, can this be
modified to do 2 or more columns?

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & endRow)

I have formulas in A2 and B2 and want to autofill at the same time instead
of separately. I tried modifying (Range("A2:B2"),etc.) but can't get it to
work.

Any help would be greatly appreciated!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Want a macro for multiple columns on current macro for column

Perfect!! Works just like I want it to! FYI - I left the endRow as Col 1
and it works!

"Rick Rothstein" wrote:

The best I can see, the code you posted won't work for your original set up
because it is searching for the endRow in the same column you want to
AutoFill. Assuming that the 1 in the endRow calculation is actually some
other column (I'll use 3 for this example), then you can do this to
accomplish what you want...

Dim endRow As Long
endRow = Cells(Rows.Count, 3).End(xlUp).Row
Range("A2:B2").AutoFill Destination:=Range("A2:B" & endRow)

Notice column designation after the colon has been changed to B in BOTH
Range function calls.

--
Rick (MVP - Excel)


"Valerie" wrote in message
...
I am currently using the following macro in many of my worksheets and love
the time it saves. It's for one column. My question is, can this be
modified to do 2 or more columns?

Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A2").AutoFill Destination:=Range("A2:A" & endRow)

I have formulas in A2 and B2 and want to autofill at the same time instead
of separately. I tried modifying (Range("A2:B2"),etc.) but can't get it to
work.

Any help would be greatly appreciated!



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
Macro to add Multiple columns jlclyde Excel Discussion (Misc queries) 5 February 3rd 09 05:27 PM
Convert macro that runs against entire column to run in current row [email protected] Excel Programming 2 August 13th 08 03:51 PM
Macro to select multiple columns bernd Excel Programming 9 June 15th 07 12:41 PM
Sum Multiple Columns with Macro Ken[_18_] Excel Programming 2 February 4th 04 12:40 AM
macro that loops to multiple columns Brad Zenner Excel Programming 1 July 22nd 03 03:17 AM


All times are GMT +1. The time now is 11:20 PM.

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

About Us

"It's about Microsoft Excel"