Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default match cell to range

Set rng = Range("H5:H200")
For Each c In rng
If c.Value = Range("X9").Value Then
FoundRow = c.Row
Range("F" & FoundRow).Value = Range("V8").Value
Exit For
End If
Next c


so i am trying to look for the value of X9 in the range h5:h200
when i find the match...i wanted to take the value of column F in the
same row as the found match, and set V8 to the same value.....
i have a feeling its not even running through the if then statement
tho....but im not sure.....
whats wrong? thx

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default match cell to range

should this
Range("F" & FoundRow).Value = Range("V8").Value

read
Range("V8").Value = Range("F" & FoundRow).Value

--
Cheers
Nigel



"Nigel" wrote in message
oups.com...
Set rng = Range("H5:H200")
For Each c In rng
If c.Value = Range("X9").Value Then
FoundRow = c.Row
Range("F" & FoundRow).Value = Range("V8").Value
Exit For
End If
Next c


so i am trying to look for the value of X9 in the range h5:h200
when i find the match...i wanted to take the value of column F in the
same row as the found match, and set V8 to the same value.....
i have a feeling its not even running through the if then statement
tho....but im not sure.....
whats wrong? thx



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default match cell to range

well i finally figured out how to use the step into feature, and found
that the script never makes it past the If Then Statement....it goes
from If Then.....to End If, to Next....it never runs the code between
the If Then and End If lines

On Nov 22, 9:39 pm, "Nigel" wrote:
should this
Range("F" & FoundRow).Value = Range("V8").Value

read
Range("V8").Value = Range("F" & FoundRow).Value

--
Cheers
Nigel

"Nigel" wrote in ooglegroups.com...



Set rng = Range("H5:H200")
For Each c In rng
If c.Value = Range("X9").Value Then
FoundRow = c.Row
Range("F" & FoundRow).Value = Range("V8").Value
Exit For
End If
Next c


so i am trying to look for the value of X9 in the range h5:h200
when i find the match...i wanted to take the value of column F in the
same row as the found match, and set V8 to the same value.....
i have a feeling its not even running through the if then statement
tho....but im not sure.....
whats wrong? thx- Hide quoted text -- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default match cell to range


Nigel,

I have tested this and it works. You must, obviously, have something in
column F of the c.Row for V8 to be populated.

Dim LoopRange
Set rng = Range("H5:H200")
For Each c In rng
If c.Value = Range("X9").Value Then
FoundRow = c.Row
Range("V8").Value = Range("F" & FoundRow).Value
Exit For
End If
Next c
End Sub

Regards

Michael Beckinsale

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default match cell to range

Another way

On Error Resume Next
iRow = Application.Match(Range("X9").Value,Range("H5:H200 "),0)
On Error Goto 0
If iRow 0 Then
Range("V8").Value = Range("H5:H200").Offset(iRow-1,-2).Value
Else
MsgBox "Not found"
End If

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Nigel" wrote in message
oups.com...
Set rng = Range("H5:H200")
For Each c In rng
If c.Value = Range("X9").Value Then
FoundRow = c.Row
Range("F" & FoundRow).Value = Range("V8").Value
Exit For
End If
Next c


so i am trying to look for the value of X9 in the range h5:h200
when i find the match...i wanted to take the value of column F in the
same row as the found match, and set V8 to the same value.....
i have a feeling its not even running through the if then statement
tho....but im not sure.....
whats wrong? thx



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
Match (1 of 3 cell values) in a range? RyanR Excel Worksheet Functions 3 December 22nd 09 05:16 AM
Conditional format if cell match found in another range of cells Nolene Excel Worksheet Functions 2 October 5th 06 06:56 AM
count if range contains match to another cell creativeops Excel Discussion (Misc queries) 7 February 23rd 06 06:22 PM
Range Match helmekki[_42_] Excel Programming 2 October 21st 04 06:06 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


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