Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default vb simple formula

Hi,

is seems simple but I cant get it to work.


this is what I'm trying to do in a module.



dim cell as range

for each cell in range ("a2:a200")


if cell.value = any cell on the second sheet range (b1 to b50 ) then


do whatever



next cell.



what is the right code to check if the current cell value is equal to any
cell in the second sheet range b1 to b50?


Thanks for your help.





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default vb simple formula

dim cell as range

for each cell in range ("a2:a200")
if application.countif(Range("B1:B50"),cell.value) 0 then
msgbox cell.Address & " Matches a value"
end if
Next

If you want to find which cell, you can use

Dim res as Variant


res = Application.Match(cell.Value,Range("B1:B50"),0)
if not iserror(res) then
msgbox cell.Address & " matches value in " & Range("B1:B50")(res).Address
End if

Regards,
Tom Ogilvy

"Cesar Zapata" wrote in message
...
Hi,

is seems simple but I cant get it to work.


this is what I'm trying to do in a module.



dim cell as range

for each cell in range ("a2:a200")


if cell.value = any cell on the second sheet range (b1 to b50 ) then


do whatever



next cell.



what is the right code to check if the current cell value is equal to any
cell in the second sheet range b1 to b50?


Thanks for your help.







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default vb simple formula

try

Sub IfCellMatch()
On Error Resume Next
For Each c In [a2:a14]
x = Sheets("data").Range("b1:b21").Find(c)
If c = x Then MsgBox c
Next
End Sub


--
Don Guillett
SalesAid Software
Granite Shoals, TX

"Cesar Zapata" wrote in message
...
Hi,

is seems simple but I cant get it to work.


this is what I'm trying to do in a module.



dim cell as range

for each cell in range ("a2:a200")


if cell.value = any cell on the second sheet range (b1 to b50 ) then


do whatever



next cell.



what is the right code to check if the current cell value is equal to any
cell in the second sheet range b1 to b50?


Thanks for your help.







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
Simple formula raff98 Excel Worksheet Functions 4 December 16th 07 07:29 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple formula Debbie Excel Discussion (Misc queries) 7 April 7th 07 11:06 AM
HELP WITH A SIMPLE FORMULA [email protected] Excel Discussion (Misc queries) 1 March 16th 07 10:16 PM


All times are GMT +1. The time now is 08:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"