Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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'

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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


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



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