View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Melanie Breden Melanie Breden is offline
external usenet poster
 
Posts: 88
Default Finding all Similarly Named Ranges?

Hi Grant,

Grant Reid wrote:
In my workbook I have two named worksheets, "Extract" and "Info".

On the worksheet "Extract" I have three named Ranges, "H1_Server_1",
"H1_Server_2", "H1_Server_3"

On the worksheet "Extract" I have three named Ranges, "H1_Server_4",
"H1_Server_5", "H1_Server_6"

I need to fashion a script that will locate any named range starting with
"H1_Server_" on any worksheet and then change the background color of the
named ranges.


try this:

Sub FormatH1()
Const strH1 As String = "H1_Server_"
Dim nName As Name

For Each nName In ActiveWorkbook.Names
If InStr(nName.Name, strH1) Then _
Range(nName).Interior.ColorIndex = 35
Next nName
End Sub


--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)