Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default activating cell which is in rowMatch, columnMatch of two given val

Dear Experts,

I cannot find any references to the following problem in any of my books,
although it seems to me it would be a common programming requirement!

I want to go to the cell in a range which is is the intersection of two
values, one in the rows, the other in the columns.

My example is a list of names in the rows, and dates in the columns. I want
to retrieve the value stored where NameX and DateY meet, but cannot find the
syntax for referencing that cell.

Any advice gratefully received.
Many thanks,

Matilda
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default activating cell which is in rowMatch, columnMatch of two given val

Give this a try...

Sub FindIntersection()
Dim rngColumnToSearch As Range
Dim rngRowToSearch As Range
Dim rngColumnFound As Range
Dim rngRowFound As Range
Dim rngIntersection As Range
Dim wks As Worksheet

'Change the sheet row and column as necessary
Set wks = Sheets("Sheet1")
Set rngColumnToSearch = wks.Columns("A")
Set rngRowToSearch = wks.Rows(1)
'Change the next 2 lines What:="???"
Set rngColumnFound = rngColumnToSearch.Find(What:="This", LookAt:=xlWhole)
Set rngRowFound = rngRowToSearch.Find(What:="That", LookAt:=xlWhole)
If Not (rngColumnFound Is Nothing Or rngRowFound Is Nothing) Then
Set rngIntersection = Intersect(rngColumnFound.EntireRow, _
rngRowFound.EntireColumn)
MsgBox rngIntersection.Address
End If

End Sub

--
HTH...

Jim Thomlinson


"Matilda" wrote:

Dear Experts,

I cannot find any references to the following problem in any of my books,
although it seems to me it would be a common programming requirement!

I want to go to the cell in a range which is is the intersection of two
values, one in the rows, the other in the columns.

My example is a list of names in the rows, and dates in the columns. I want
to retrieve the value stored where NameX and DateY meet, but cannot find the
syntax for referencing that cell.

Any advice gratefully received.
Many thanks,

Matilda

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default activating cell which is in rowMatch, columnMatch of two given


Thanks Jim, your code works exactly as I require.
I had written a do...while loop to find the name, and another for the dates,
but didn't know how to extract the Row value and the Column value from the
address to create the address of the intersection. I thought there would be
a means of referencing these values as variables in vba, but oviously not.
Your code is also a much neater way of arriving at the required addresses.
I'm learning the excel inbuilt functions slowly, and this sort of example
helps heaps.

Much obliged,

Matilda


"Jim Thomlinson" wrote:

Give this a try...

Sub FindIntersection()
Dim rngColumnToSearch As Range
Dim rngRowToSearch As Range
Dim rngColumnFound As Range
Dim rngRowFound As Range
Dim rngIntersection As Range
Dim wks As Worksheet

'Change the sheet row and column as necessary
Set wks = Sheets("Sheet1")
Set rngColumnToSearch = wks.Columns("A")
Set rngRowToSearch = wks.Rows(1)
'Change the next 2 lines What:="???"
Set rngColumnFound = rngColumnToSearch.Find(What:="This", LookAt:=xlWhole)
Set rngRowFound = rngRowToSearch.Find(What:="That", LookAt:=xlWhole)
If Not (rngColumnFound Is Nothing Or rngRowFound Is Nothing) Then
Set rngIntersection = Intersect(rngColumnFound.EntireRow, _
rngRowFound.EntireColumn)
MsgBox rngIntersection.Address
End If

End Sub

--
HTH...

Jim Thomlinson


"Matilda" wrote:

Dear Experts,

I cannot find any references to the following problem in any of my books,
although it seems to me it would be a common programming requirement!

I want to go to the cell in a range which is is the intersection of two
values, one in the rows, the other in the columns.

My example is a list of names in the rows, and dates in the columns. I want
to retrieve the value stored where NameX and DateY meet, but cannot find the
syntax for referencing that cell.

Any advice gratefully received.
Many thanks,

Matilda

  #4   Report Post  
Posted to microsoft.public.excel.programming
dkk dkk is offline
external usenet poster
 
Posts: 8
Default activating cell which is in rowMatch, columnMatch of two given

I found this code & is very close to what I need! Since I'm a novice at code
writing, I find what I need & then try to modify. I think this will work but
I need a "do loop" to select "This" and "That" (see original code) from a two
column table. (The code seems to work if I put in location of Ang & Rol in
place of "This" & "That"):

Set rngColumnFound = rngColumnToSearch.Find(What:=[F5], LookAt:=xlWhole)
Set rngRowFound = rngRowToSearch.Find(What:=[G5], LookAt:=xlWhole)

but I need to loop through the table. Can anyone help?

example table (of course table can have "n" rows):

Ang (Col F) Rol (Col G)
Row 5 2 2
2 4
4 6
n n

Thanks in advance,
dkk



"Matilda" wrote:


Thanks Jim, your code works exactly as I require.
I had written a do...while loop to find the name, and another for the dates,
but didn't know how to extract the Row value and the Column value from the
address to create the address of the intersection. I thought there would be
a means of referencing these values as variables in vba, but oviously not.
Your code is also a much neater way of arriving at the required addresses.
I'm learning the excel inbuilt functions slowly, and this sort of example
helps heaps.

Much obliged,

Matilda


"Jim Thomlinson" wrote:

Give this a try...

Sub FindIntersection()
Dim rngColumnToSearch As Range
Dim rngRowToSearch As Range
Dim rngColumnFound As Range
Dim rngRowFound As Range
Dim rngIntersection As Range
Dim wks As Worksheet

'Change the sheet row and column as necessary
Set wks = Sheets("Sheet1")
Set rngColumnToSearch = wks.Columns("A")
Set rngRowToSearch = wks.Rows(1)
'Change the next 2 lines What:="???"
Set rngColumnFound = rngColumnToSearch.Find(What:="This", LookAt:=xlWhole)
Set rngRowFound = rngRowToSearch.Find(What:="That", LookAt:=xlWhole)
If Not (rngColumnFound Is Nothing Or rngRowFound Is Nothing) Then
Set rngIntersection = Intersect(rngColumnFound.EntireRow, _
rngRowFound.EntireColumn)
MsgBox rngIntersection.Address
End If

End Sub

--
HTH...

Jim Thomlinson


"Matilda" wrote:

Dear Experts,

I cannot find any references to the following problem in any of my books,
although it seems to me it would be a common programming requirement!

I want to go to the cell in a range which is is the intersection of two
values, one in the rows, the other in the columns.

My example is a list of names in the rows, and dates in the columns. I want
to retrieve the value stored where NameX and DateY meet, but cannot find the
syntax for referencing that cell.

Any advice gratefully received.
Many thanks,

Matilda

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
Activating a sound alert on cell value Sebastian Flyte Excel Discussion (Misc queries) 0 December 28th 09 04:12 PM
Activating object from Excel cell Amnon Wilensky Excel Worksheet Functions 2 March 29th 09 06:46 PM
Activating the next cell Bhupinder Rayat Excel Programming 1 October 6th 05 12:52 PM
Activating cell in a file Roger Excel Discussion (Misc queries) 2 July 7th 05 10:52 PM
Selecting or Activating a cell. Scott Excel Programming 0 August 15th 03 09:22 AM


All times are GMT +1. The time now is 03:39 AM.

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"