Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Excel2000: Searching a value in named range

Hi

In a workbook I have a named range Weeks, which contains string values in
format "yyyy.ww". What is the best way to find the position of string value
XWeek (which equals p.e. to "2006.01") in range Weeks using VBA?

I can get the range definition
ThisWorkbook.Names("Weeks")
, but I haven't find a way to search in it.
Of-course I can read the range into VBA as an array, add a couple of array
search functions I have written before for some other project, and search
this array, but maybe there is an easier way.


Thanks in advance

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel2000: Searching a value in named range

Arvi,

Have you tried adding the sheet and using Find

ThisWorkbook.ActiveSheet.Range("Weeks").Find(XWeek ).Select


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Arvi Laanemets" wrote in message
...
Hi

In a workbook I have a named range Weeks, which contains string values in
format "yyyy.ww". What is the best way to find the position of string

value
XWeek (which equals p.e. to "2006.01") in range Weeks using VBA?

I can get the range definition
ThisWorkbook.Names("Weeks")
, but I haven't find a way to search in it.
Of-course I can read the range into VBA as an array, add a couple of array
search functions I have written before for some other project, and search
this array, but maybe there is an easier way.


Thanks in advance

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Excel2000: Searching a value in named range

Arvi,

Range("Weeks").Find(What:="2006.01")

Returns a cell that you can use Row/Column properties to return location
details.

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Arvi Laanemets" wrote:

Hi

In a workbook I have a named range Weeks, which contains string values in
format "yyyy.ww". What is the best way to find the position of string value
XWeek (which equals p.e. to "2006.01") in range Weeks using VBA?

I can get the range definition
ThisWorkbook.Names("Weeks")
, but I haven't find a way to search in it.
Of-course I can read the range into VBA as an array, add a couple of array
search functions I have written before for some other project, and search
this array, but maybe there is an easier way.


Thanks in advance

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Excel2000: Searching a value in named range

Arvi, Here is some code that I believe will get you started...

Good Luck, Rick


Option Explicit
Sub SearchFor()
Dim searchRng as Range, Frng as Range

Set searchRng = Range("Weeks")

Set Frng = searchRng.Find(what:="2006.01", LookIn:=xlValues,
lookat:=xlWhole)
If Not Frng Is Nothing Then
msgbox("2006.01 found at " & Frng.Address)
else
msgbox("2006.01 not found")
End If

End Sub

"Arvi Laanemets" wrote in message
...
Hi

In a workbook I have a named range Weeks, which contains string values in
format "yyyy.ww". What is the best way to find the position of string

value
XWeek (which equals p.e. to "2006.01") in range Weeks using VBA?

I can get the range definition
ThisWorkbook.Names("Weeks")
, but I haven't find a way to search in it.
Of-course I can read the range into VBA as an array, add a couple of array
search functions I have written before for some other project, and search
this array, but maybe there is an easier way.


Thanks in advance

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Excel2000: Searching a value in named range

Hi

I decided for
Application.WorksheetFunction.Match(EndWeek,
ThisWorkbook.Sheets("Weeks").Range("Weeks"), 0)

Thanks anyway - following your tips I found out, that I have always to
determine sheet name, when referring to range on it.


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"Arvi Laanemets" wrote in message
...
Hi

In a workbook I have a named range Weeks, which contains string values in
format "yyyy.ww". What is the best way to find the position of string
value XWeek (which equals p.e. to "2006.01") in range Weeks using VBA?

I can get the range definition
ThisWorkbook.Names("Weeks")
, but I haven't find a way to search in it.
Of-course I can read the range into VBA as an array, add a couple of array
search functions I have written before for some other project, and search
this array, but maybe there is an easier way.


Thanks in advance

--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )





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
Excel2000:How to link Print Area with a named range Arvi Laanemets Excel Discussion (Misc queries) 5 April 8th 08 02:35 PM
Excel2000:How to link Print Area with a named range Arvi Laanemets Excel Worksheet Functions 5 April 8th 08 02:35 PM
Excel2000: Custom data validation and named ranges Arvi Laanemets Excel Discussion (Misc queries) 9 December 10th 04 07:05 PM
Excel2000: Reading Named Range value from VBA Arvi Laanemets Excel Programming 2 July 9th 04 09:01 AM
Excel2000: finding last row of used range Arvi Laanemets Excel Programming 2 May 10th 04 08:54 AM


All times are GMT +1. The time now is 12:21 PM.

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"