Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi all,
How do you progammaticly refer to named ranges. I am trying to write a macro that loops through named ranges to find items. I have the macro mostly written and can loop through sheets but i want it to loop through 4 named ranges only because it may find the items outside the ranges which i don't want. It does return the range address but not the sheet name. can someone point me in the right direction. Zoomer progress so far.......... Sub macfind() Dim sStr As String Dim sh As Worksheet Dim rng As Range Dim Item1 As Range Dim Item2 As Range sStr = InputBox("Enter item to search for") For Each sh In ThisWorkbook.Worksheets If sStr < "" Then Set rng = Nothing Set rng = sh.Range("A1:IV65536").Find(What:=sStr, _ After:=sh.Range("A1"), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) End If If Not rng Is Nothing Then Sheets("sheet1").Activate Range("AA1").End(xlDown).Offset(1, 0).Select ActiveCell.Value = rng.Address End If Next sh If rng Is Nothing Then MsgBox sStr & " was Not found" End If End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Range("MyName").Find
-- Regards, Tom Ogilvy "Zoomer" wrote in message ... hi all, How do you progammaticly refer to named ranges. I am trying to write a macro that loops through named ranges to find items. I have the macro mostly written and can loop through sheets but i want it to loop through 4 named ranges only because it may find the items outside the ranges which i don't want. It does return the range address but not the sheet name. can someone point me in the right direction. Zoomer progress so far.......... Sub macfind() Dim sStr As String Dim sh As Worksheet Dim rng As Range Dim Item1 As Range Dim Item2 As Range sStr = InputBox("Enter item to search for") For Each sh In ThisWorkbook.Worksheets If sStr < "" Then Set rng = Nothing Set rng = sh.Range("A1:IV65536").Find(What:=sStr, _ After:=sh.Range("A1"), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) End If If Not rng Is Nothing Then Sheets("sheet1").Activate Range("AA1").End(xlDown).Offset(1, 0).Select ActiveCell.Value = rng.Address End If Next sh If rng Is Nothing Then MsgBox sStr & " was Not found" End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
converting email address names in a range of cells to real names | Excel Worksheet Functions | |||
How to Delete blanks between a range and populate only the names inthe given range | Excel Discussion (Misc queries) | |||
COPYING FORMULA CONTAINING NAMES/RELATIVE RANGE NAMES | Excel Discussion (Misc queries) | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
Range Names | Excel Programming |