Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is it possible to write an "If/Then" procedure that evaluates if a give cell value is equal to any cell value within a range of cells the return the value of another cell in the same row as the equalled cell e.g. For n = 1 to 16 If Cells(n, "A").Value = The value of any cell between (n + 18. "A" and (n + 50, "A) Then Cells(n, "B").Value = (Equaled N + row, "B").Value Looks like it should be doable but I can'T -- knowtrum ----------------------------------------------------------------------- knowtrump's Profile: http://www.excelforum.com/member.php...fo&userid=1966 View this thread: http://www.excelforum.com/showthread.php?threadid=51416 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "knowtrump" wrote in message ... Is it possible to write an "If/Then" procedure that evaluates if a given cell value is equal to any cell value within a range of cells then return the value of another cell in the same row as the equalled cell? e.g. For n = 1 to 16 If Cells(n, "A").Value = The value of any cell between (n + 18. "A") and (n + 50, "A) Then Cells(n, "B").Value = (Equaled N + row, "B").Value Looks like it should be doable but I can'T' -- knowtrump ------------------------------------------------------------------------ knowtrump's Profile: http://www.excelforum.com/member.php...o&userid=19664 View this thread: http://www.excelforum.com/showthread...hreadid=514161 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
With Range("B1:B16") .Formula = "=IF(ISNA(MATCH(A1,A19:A51,FALSE)),""""," & _ "VLOOKUP(A1,A19:B51,2,FALSE))" .Value = .Value End With In article , knowtrump wrote: Is it possible to write an "If/Then" procedure that evaluates if a given cell value is equal to any cell value within a range of cells then return the value of another cell in the same row as the equalled cell? e.g. For n = 1 to 16 If Cells(n, "A").Value = The value of any cell between (n + 18. "A") and (n + 50, "A) Then Cells(n, "B").Value = (Equaled N + row, "B").Value Looks like it should be doable but I can'T' |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() JE Could you please "Comment" your solution. When I run it it simply erases my data. -- knowtrump ------------------------------------------------------------------------ knowtrump's Profile: http://www.excelforum.com/member.php...o&userid=19664 View this thread: http://www.excelforum.com/showthread...hreadid=514161 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If data exsits in B1:B16 prior to running the code, then if no match is found
for a given A1:A16 value, the corresponding B value will be set to blank. Is this what's happening? If so, try: For i = 1 To 16 res = Application.Match(Range("a" & i), Range("a" & i + 18 & ":a" & i + 50), False) If Not IsError(res) Then Cells(i, 2) = Application.VLookup(Range("a" & i), Range("a" & i + 18 & ":B" & i + 50), 2, False) End If Next i "knowtrump" wrote: JE Could you please "Comment" your solution. When I run it it simply erases my data. -- knowtrump ------------------------------------------------------------------------ knowtrump's Profile: http://www.excelforum.com/member.php...o&userid=19664 View this thread: http://www.excelforum.com/showthread...hreadid=514161 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|