Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default VBA to autofill from relative location

If I need to autofill column B from the last cell that has data in it to the
same row as the last cell of column A that has data in it, how do I set the
destination for the autofill correctly?



I have tried a lot of ways that seemed obvious and all of them return errors.


Here is where I am stuck:

Selection.AutoFill Destination:=Range(B[this number is the active cell, or
the one I just put a value in in column B]:B[this number should be the same
as the last cell that has a value in it in column A])


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default VBA to autofill from relative location

Try

Dim lngRow As Long

lngRow = Cells(Rows.Count, "A").End(xlUp).Row
Selection.AutoFill Destination:=Range("B" & ActiveCell.Row & ":B" & lngRow)


--
Jacob (MVP - Excel)


"AlexJarvis" wrote:

If I need to autofill column B from the last cell that has data in it to the
same row as the last cell of column A that has data in it, how do I set the
destination for the autofill correctly?



I have tried a lot of ways that seemed obvious and all of them return errors.


Here is where I am stuck:

Selection.AutoFill Destination:=Range(B[this number is the active cell, or
the one I just put a value in in column B]:B[this number should be the same
as the last cell that has a value in it in column A])


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default VBA to autofill from relative location

Good deal, thank you!

I was forgetting to put a "&" in there...

-A

"Jacob Skaria" wrote:

Try

Dim lngRow As Long

lngRow = Cells(Rows.Count, "A").End(xlUp).Row
Selection.AutoFill Destination:=Range("B" & ActiveCell.Row & ":B" & lngRow)


--
Jacob (MVP - Excel)


"AlexJarvis" wrote:

If I need to autofill column B from the last cell that has data in it to the
same row as the last cell of column A that has data in it, how do I set the
destination for the autofill correctly?



I have tried a lot of ways that seemed obvious and all of them return errors.


Here is where I am stuck:

Selection.AutoFill Destination:=Range(B[this number is the active cell, or
the one I just put a value in in column B]:B[this number should be the same
as the last cell that has a value in it in column A])


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
How to read value of a cell in a relative location AnatolyV Excel Worksheet Functions 1 July 20th 09 02:39 AM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
~ ~ ~ Its All Relative??? 23hitman Excel Discussion (Misc queries) 4 October 19th 08 02:24 AM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Relative reference autofill increment other than +1 SteveB Excel Discussion (Misc queries) 3 June 14th 05 07:40 PM


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