Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default finding corresponding row

In Sheet A of data, in Column B, I have a year (say, 2003). For each row
(and year) in Sheet A, I'm trying to get the macro to find the row of the
corresponding (identical) year on Sheet B, then copy the appropriate data
box for that row, and enter it into an equation with a data box from the
initial row in Sheet A. I'm having a difficult time figuring how how to get
the macro to do that recognition process, and then to capture the right
cell. Can anyone please help with this? Thanks.

Best,
Luke


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default finding corresponding row

Hi,
This should get you started. You may need to change 'MatchRng' to
correspond to the column with the year data.

Pass the Year from SheetA as the parameter . If no match is found it
returns 0.

e.g Call Findrow(Range("B3").value)

HTH

Function FindRow(ByVal MatchVal As Integer)
Dim Lastrow As Integer, mRow As Integer, Matchrng As Range, c As Variant

With Worksheets("SheetB")
Lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
Set Matchrng = .Range("b2:B" & Lastrow) ' Change as required
Set c = Matchrng.Find(MatchVal, LookIn:=xlValues) ' Change as required
If c Is Nothing Then
MsgBox MatchVal & " not found"
FindRow = 0
Else
FindRow = c.Row
End If
End With

End Function

"Lucas Tate" wrote:

In Sheet A of data, in Column B, I have a year (say, 2003). For each row
(and year) in Sheet A, I'm trying to get the macro to find the row of the
corresponding (identical) year on Sheet B, then copy the appropriate data
box for that row, and enter it into an equation with a data box from the
initial row in Sheet A. I'm having a difficult time figuring how how to get
the macro to do that recognition process, and then to capture the right
cell. Can anyone please help with this? Thanks.

Best,
Luke



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default finding corresponding row

Sorry ..

Should be MyRow=FindRow(Range("B3").value)


"Toppers" wrote:

Hi,
This should get you started. You may need to change 'MatchRng' to
correspond to the column with the year data.

Pass the Year from SheetA as the parameter . If no match is found it
returns 0.

e.g Call Findrow(Range("B3").value)

HTH

Function FindRow(ByVal MatchVal As Integer)
Dim Lastrow As Integer, mRow As Integer, Matchrng As Range, c As Variant

With Worksheets("SheetB")
Lastrow = .Cells(Rows.Count, "B").End(xlUp).Row
Set Matchrng = .Range("b2:B" & Lastrow) ' Change as required
Set c = Matchrng.Find(MatchVal, LookIn:=xlValues) ' Change as required
If c Is Nothing Then
MsgBox MatchVal & " not found"
FindRow = 0
Else
FindRow = c.Row
End If
End With

End Function

"Lucas Tate" wrote:

In Sheet A of data, in Column B, I have a year (say, 2003). For each row
(and year) in Sheet A, I'm trying to get the macro to find the row of the
corresponding (identical) year on Sheet B, then copy the appropriate data
box for that row, and enter it into an equation with a data box from the
initial row in Sheet A. I'm having a difficult time figuring how how to get
the macro to do that recognition process, and then to capture the right
cell. Can anyone please help with this? Thanks.

Best,
Luke



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
Finding 1st,2nd,3rd etc checkQ Excel Discussion (Misc queries) 5 May 19th 08 12:38 AM
Finding the value of x bpiepkorn Excel Worksheet Functions 4 July 26th 07 04:02 PM
Finding Max or Min Value [email protected] Excel Discussion (Misc queries) 4 November 24th 06 09:39 AM
Finding value tkaplan Excel Discussion (Misc queries) 2 October 21st 05 08:19 PM
Finding max value paradise Excel Programming 2 November 7th 03 01:42 AM


All times are GMT +1. The time now is 12:22 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"