Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
concatenate cells by a given range | Excel Worksheet Functions | |||
function to concatenate range | Excel Discussion (Misc queries) | |||
concatenate a range function | Excel Worksheet Functions | |||
Sum cells based on a row variable and seperate column variable | Excel Worksheet Functions | |||
Concatenate a range | Excel Worksheet Functions |