create named range in each sheet in workbook

  • Thread starter Thread starter davegb
  • Start date Start date
D

davegb

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.
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top