Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Autofill to last cell in other column

How can I autofill the selected cell down in the selected column to the last
cell in the column to the right? I'd also like to exclude cells where the
cell to the right is null. Thank you very much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Autofill to last cell in other column

Hi Alex,

Assuming that you want to create the autofill programatically, rather than
manualy, the macro below should give you what you want, except the exluding
of null cells.

The only way to effect such an exlusion would be to delete the null rows
before the autofill.

Sub FillToLastRow()

Dim LastRow As Long
Dim FillRange As String
Dim FillColumn As Long


'###### Firstly Select the item you want to copy in the autofill column
'then run this macro

'Determines the column number of rhe selcted cell
FillColumn = ActiveCell.Column

'Determines the last used row in the
'first column to the right of the selected
'autofill column
LastRow = Cells(Rows.Count, FillColumn + 1).End(xlUp).Row

'Creates the autofill range address in string format
FillRange = Range(Cells(ActiveCell.Row, FillColumn), _
Cells(LastRow, FillColumn)).Address

'Autofills the selected column
'to the last row number, determined
'from the next column to the right
ActiveCell.AutoFill Destination:=Range(FillRange)

End Sub


--
Regards
John Howard
Sydney, Australia


"Alex" wrote:

How can I autofill the selected cell down in the selected column to the last
cell in the column to the right? I'd also like to exclude cells where the
cell to the right is null. Thank you very much.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Autofill to last cell in other column

This is perfect! Thank you so much.

"John Howard" wrote:

Hi Alex,

Assuming that you want to create the autofill programatically, rather than
manualy, the macro below should give you what you want, except the exluding
of null cells.

The only way to effect such an exlusion would be to delete the null rows
before the autofill.

Sub FillToLastRow()

Dim LastRow As Long
Dim FillRange As String
Dim FillColumn As Long


'###### Firstly Select the item you want to copy in the autofill column
'then run this macro

'Determines the column number of rhe selcted cell
FillColumn = ActiveCell.Column

'Determines the last used row in the
'first column to the right of the selected
'autofill column
LastRow = Cells(Rows.Count, FillColumn + 1).End(xlUp).Row

'Creates the autofill range address in string format
FillRange = Range(Cells(ActiveCell.Row, FillColumn), _
Cells(LastRow, FillColumn)).Address

'Autofills the selected column
'to the last row number, determined
'from the next column to the right
ActiveCell.AutoFill Destination:=Range(FillRange)

End Sub


--
Regards
John Howard
Sydney, Australia


"Alex" wrote:

How can I autofill the selected cell down in the selected column to the last
cell in the column to the right? I'd also like to exclude cells where the
cell to the right is null. Thank you very much.

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 column from data (code) in column next to it Matt Excel Worksheet Functions 4 April 24th 09 06:17 PM
Automating to autofill column B based on column A entry GirlFridayCA Excel Discussion (Misc queries) 2 December 2nd 08 10:46 PM
VBA to autofill next blank cell in same column manfareed Excel Programming 8 September 28th 07 05:12 PM
Identify Last Cell and autofill last column manfareed Excel Programming 4 September 27th 07 03:02 AM
Autofill Column D based on input in Column C Helen McClaine Excel Discussion (Misc queries) 1 April 5th 05 09:11 PM


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