Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Match (1 of 3 cell values) in a range? | Excel Worksheet Functions | |||
Conditional format if cell match found in another range of cells | Excel Worksheet Functions | |||
count if range contains match to another cell | Excel Discussion (Misc queries) | |||
Range Match | Excel Programming | |||
Range.Find returns cell outside of range when range set to single cell | Excel Programming |