A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA to autofill from relative location



 
 
Thread Tools Display Modes
  #1  
Old April 30th, 2010, 04:17 PM posted to microsoft.public.excel.worksheet.functions
AlexJarvis
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  
Old April 30th, 2010, 04:24 PM posted to microsoft.public.excel.worksheet.functions
Jacob Skaria
external usenet poster
 
Posts: 5,952
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  
Old April 30th, 2010, 04:47 PM posted to microsoft.public.excel.worksheet.functions
AlexJarvis
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])


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:46 AM.


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