Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.dotnet.framework,microsoft.public.dotnet.languages.csharp,microsoft.public.dotnet.languages.vb,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the position of a cell in Excel named range?

'** The code to search some value in the named range
Sub searchInRange(RangeName As String, Value As String)

Dim namedRange As Range
Dim rangecells As Range

Dim mIntCells As Integer
Dim mIntCtr As Integer


Set namedRange = Names(RangeName).RefersToRange
mIntCells = namedRange.Count
Set rangecells = namedRange.Cells

For mIntCtr = 1 To mIntCells
If rangecells.Item(mIntCtr) = Value Then
MsgBox "got it at : " & "row - " & rangecells.Item(mIntCtr).Row & _
"col - " & rangecells.Item(mIntCtr).Column & " -- " &
rangecells.Item(mIntCtr).Address
Exit For
Else
Debug.Print rangecells.Item(mIntCtr).Value
End If
Next
End Sub

'** This is how you will call it
call searchInRange("myrange", "myvalue")

HTH
Kalpesh

"Alan White" wrote in message
...
Hi Groups, I'd like to know if someone could show me how to get the

position
(col, row) of a cell in excel named range. What I need to do is: I will
need to loop through a named range to find a particular cell by value,

once
I found it, I need to know the position of that cell. I'm doing this with
C#, but any VB code would be help too. Thanks!.




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
Referring to specific cell in named range in Excel formula Nigel Barton Excel Worksheet Functions 3 August 18th 09 04:25 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Position of a cell in a range zangief Excel Worksheet Functions 4 September 27th 05 03:07 PM
How to get the position of a cell in Excel named range? [email protected] Excel Programming 0 July 10th 03 03:14 AM
How to get the position of a cell in Excel named range? acw Excel Programming 0 July 10th 03 02:57 AM


All times are GMT +1. The time now is 04:45 PM.

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

About Us

"It's about Microsoft Excel"