Check to see if variable is duplicate.

  • Thread starter Thread starter ianripping
  • Start date Start date
I

ianripping

I am grabbing var1 from an inputbox.

I want to say if var1 = any of the values entered in cells b4:b32 the
goto Double

I tired

if var1 = range("b4:b32").value then goto double

but didnt work, any suggestions
 
On Error Resume Next
iPos = Application.Match(var1, Range("B4:B32"), 0)
If iPos > 0 Then _
MsgBox "hello"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
bob, even if that value doesnt appear, it stil reports it as bein
there
 
Ian,

You must declare iPos as a long to get this to work. If it defaults to
variant, it will always be > 0

Dim iPos As Long

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Could it be that iPos is declared as a global variable?
It might still retain it's previous result, even after Application.Match
errors.

Before Application.Match:
iPos = 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top