ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another If/Then ? (https://www.excelbanter.com/excel-programming/353744-another-if-then.html)

knowtrump[_20_]

Another If/Then ?
 

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


Barb Reinhardt

Another If/Then ?
 

"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




JE McGimpsey

Another If/Then ?
 
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'


knowtrump[_21_]

Another If/Then ?
 

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


Toppers

Another If/Then ?
 
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




All times are GMT +1. The time now is 07:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com