Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 111
Default Concatenate column with variable to set a range

i have a macro which finds the last row and returns the value Last Row. i
want to use this info to auto fill a range - Selection.AutoFill
Destination:=Range("B10:B & LastRow"). I get an error message when i try
this. should i name the variable LastRow at the beginning of the macro? or
is there something wrong with the placement of the quote marks?

thanks in advance for your help
--
aprilshowers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Concatenate column with variable to set a range

Maybe it's not the destination:= portion's fault.

What's selected?

If you're trying to fill the range and you know what it is, you might as well be
specific:

Dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("b10").autofill _
destination:=.range("B10:B" & lastrow)
end with

I used column A to determine the last row and filled B10 down to that last row.

april wrote:

i have a macro which finds the last row and returns the value Last Row. i
want to use this info to auto fill a range - Selection.AutoFill
Destination:=Range("B10:B & LastRow"). I get an error message when i try
this. should i name the variable LastRow at the beginning of the macro? or
is there something wrong with the placement of the quote marks?

thanks in advance for your help
--
aprilshowers


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Concatenate column with variable to set a range

Change Range("B10:B & LastRow") to the following:

Range("B10:B" & LastRow)

If you still get an error check to see if the the first line in your module
says "Option Explicit" and if it does you'll have to declare the LastRow
variable with a Dim statement before you can assign a value to it.
--
Kevin Backmann


"april" wrote:

i have a macro which finds the last row and returns the value Last Row. i
want to use this info to auto fill a range - Selection.AutoFill
Destination:=Range("B10:B & LastRow"). I get an error message when i try
this. should i name the variable LastRow at the beginning of the macro? or
is there something wrong with the placement of the quote marks?

thanks in advance for your help
--
aprilshowers

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
concatenate cells by a given range Twan Kennis Excel Worksheet Functions 4 July 1st 06 12:54 AM
function to concatenate range GoBobbyGo Excel Discussion (Misc queries) 2 April 19th 06 01:34 AM
concatenate a range function Wildaz Excel Worksheet Functions 7 March 15th 06 07:10 PM
Sum cells based on a row variable and seperate column variable CheeseHeadTransplant Excel Worksheet Functions 10 September 23rd 05 06:59 PM
Concatenate a range King Excel Worksheet Functions 3 March 11th 05 09:10 PM


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