ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   create named range in each sheet in workbook (https://www.excelbanter.com/excel-programming/326363-create-named-range-each-sheet-workbook.html)

davegb

create named range in each sheet in workbook
 
I'm using this code to delineate the range I want filters applied to:

Range(Range("b3"), Range("b3").End(xlDown).End(xlToRight) _
.Offset(-1, 2)).Select

Now I want a macro to go into every worksheet in the workbook, the
number may vary, and create a named range called FilterRange with the
worksheet's name. Than I can use that named range to apply filters to
from buttons/macros. Can anyone help me here?
Thanks in advance.


Ed

create named range in each sheet in workbook
 
I would Dim wks As Worksheet and Dim strName As String, then
For Each wks In WhateverWorkbook
strName = wks.Name
strName = strName & "FilterRange"
' set range, using strName as the name
Next wks

HTH
Ed

"davegb" wrote in message
oups.com...
I'm using this code to delineate the range I want filters applied to:

Range(Range("b3"), Range("b3").End(xlDown).End(xlToRight) _
.Offset(-1, 2)).Select

Now I want a macro to go into every worksheet in the workbook, the
number may vary, and create a named range called FilterRange with the
worksheet's name. Than I can use that named range to apply filters to
from buttons/macros. Can anyone help me here?
Thanks in advance.




Bob Phillips[_6_]

create named range in each sheet in workbook
 
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
With sh
.Range(.Range("B3"), .Range("B3").End(xlDown).End(xlToRight) _
.Offset(-1, 2)).Name = "'" & sh.Name & "'!FilterRange"
End With
Next sh


--

HTH

RP
(remove nothere from the email address if mailing direct)


"davegb" wrote in message
oups.com...
I'm using this code to delineate the range I want filters applied to:

Range(Range("b3"), Range("b3").End(xlDown).End(xlToRight) _
.Offset(-1, 2)).Select

Now I want a macro to go into every worksheet in the workbook, the
number may vary, and create a named range called FilterRange with the
worksheet's name. Than I can use that named range to apply filters to
from buttons/macros. Can anyone help me here?
Thanks in advance.




davegb

create named range in each sheet in workbook
 
Thanks Bob and Ed! Got it working.



All times are GMT +1. The time now is 06:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com