#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default range names

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default range names

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting email address names in a range of cells to real names John Excel Worksheet Functions 1 May 19th 10 03:44 PM
How to Delete blanks between a range and populate only the names inthe given range Yuvraj Excel Discussion (Misc queries) 2 November 4th 09 08:32 PM
COPYING FORMULA CONTAINING NAMES/RELATIVE RANGE NAMES Bricol Excel Discussion (Misc queries) 0 July 8th 08 03:54 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Range Names Helen Trim[_4_] Excel Programming 2 October 12th 04 06:16 PM


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"