Thread
:
How to set named range in macro?
View Single Post
#
5
Posted to microsoft.public.excel.programming
davegb
external usenet poster
Posts: 573
How to set named range in macro?
Don Guillett wrote:
see if this works?
Sub namerange()
Range("b3").CurrentRegion.Name = "rCtyShtFltRng"
End Sub
Thanks, Don, but I chose the column and row to determine the range
because I have blanks and merged cells in the sheet.
--
Don Guillett
SalesAid Software
"davegb" wrote in message
oups.com...
I have a macro that is called each time a different sheet in the
workbook is selected. The macro is supposed to define the determined
range as a named ramge, "FilterRange".
Sub CtyShtFltRng()
Dim lCol as Long
Dim lRow As Long
Dim wActSheet As Worksheet
Set wActSheet = ActiveSheet
Set rStart = Range("B3")
lRow = rStart.End(xlDown).Row - 1
lCol = rStart.End(xlToRight).Column
Set rCtyShtFltRng = Range(rStart, Cells(lRow, lCol))
Set wActSheet.Names("FilterRange") = rCtyShtFltRng <---ERROR
wActSheet.Range("FilterRange").Select
End Sub
I'm getting an "wrong number of arguments or invlalid property
assignment" at the marked line. I've tried about 10 or 12 variations on
this line, but none worked. Can someone tell me how to make this work?
Thanks!
Reply With Quote
davegb
View Public Profile
Find all posts by davegb