Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to "translate" that in VBA ?

Hi,

At the moment I have something like this :


/////////////////////////////////////////////////////////////////


If ActiveCell.Value = "3" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dsfdskf" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "aaaa" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dbbbb" Then
ActiveCell.Value = "Ok"
End If
End If
End If
End If

//////////////////////////////////////////////////////////////////


As it is not very efficient, I would like to put all my criteria
(dsfdskf, aaaa,...) in an an other excell sheet (sheet2) and d
something in VBA like

If ActiveCel.value = any of the value from Range A1 to A30 of sheet
Then
ActiveCell.Value - "ok"
End if

Could someone help me to do that ?

Many thanks in advance,

Gre

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to "translate" that in VBA ?

Dim res as variant
res = Application.Match(activecell.Value, worksheets("Sheet3") _
.Range("A1:A50"),0)
if not iserror(res) then
activecell.value = "Ok"
end if


note that "3" < 3 so if you might have a number 3 in the activecell, then
you need to include both a 3 and "3" in the lookup range.
--
Regards,
Tom Ogilvy

"Grek " wrote in message
...
Hi,

At the moment I have something like this :


/////////////////////////////////////////////////////////////////


If ActiveCell.Value = "3" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dsfdskf" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "aaaa" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dbbbb" Then
ActiveCell.Value = "Ok"
End If
End If
End If
End If

//////////////////////////////////////////////////////////////////


As it is not very efficient, I would like to put all my criterias
(dsfdskf, aaaa,...) in an an other excell sheet (sheet2) and do
something in VBA like

If ActiveCel.value = any of the value from Range A1 to A30 of sheet2
Then
ActiveCell.Value - "ok"
End if

Could someone help me to do that ?

Many thanks in advance,

Greg


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default How to "translate" that in VBA ?

Grek,
something like this

Dim rng As String
Dim l As String
rng = "Sheet2!$A$2:$A$31"
l = ActiveCell.Value
If Not IsError(Evaluate("Match(" & Chr(34) & l & _
Chr(34) & "," & rng & ",0)")) Then
ActiveCell.Value = "ok"
End If

Cecil


"Grek " wrote in message
...
Hi,

At the moment I have something like this :


/////////////////////////////////////////////////////////////////


If ActiveCell.Value = "3" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dsfdskf" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "aaaa" Then
ActiveCell.Value = "Ok"
If ActiveCell.Value = "dbbbb" Then
ActiveCell.Value = "Ok"
End If
End If
End If
End If

//////////////////////////////////////////////////////////////////


As it is not very efficient, I would like to put all my criterias
(dsfdskf, aaaa,...) in an an other excell sheet (sheet2) and do
something in VBA like

If ActiveCel.value = any of the value from Range A1 to A30 of sheet2
Then
ActiveCell.Value - "ok"
End if

Could someone help me to do that ?

Many thanks in advance,

Greg


---
Message posted from http://www.ExcelForum.com/



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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
"translate" numbers into words MivPiv Excel Discussion (Misc queries) 3 June 10th 06 01:12 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 05:12 AM.

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"