ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check to see if variable is duplicate. (https://www.excelbanter.com/excel-programming/297676-check-see-if-variable-duplicate.html)

ianripping[_59_]

Check to see if variable is duplicate.
 
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

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


Bob Phillips[_6_]

Check to see if variable is duplicate.
 
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)

"ianripping " wrote in message
...
I am grabbing var1 from an inputbox.

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

I tired

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

but didnt work, any suggestions?


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




ianripping[_60_]

Check to see if variable is duplicate.
 
Thanks bo

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


ianripping[_61_]

Check to see if variable is duplicate.
 
bob, even if that value doesnt appear, it stil reports it as bein
there

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


Bob Phillips[_6_]

Check to see if variable is duplicate.
 
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)

"ianripping " wrote in message
...
bob, even if that value doesnt appear, it stil reports it as being
there!


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




ianripping[_62_]

Check to see if variable is duplicate.
 
ok did that, still doing the sam

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


Rob van Gelder[_4_]

Check to see if variable is duplicate.
 
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

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"ianripping " wrote in message
...
ok did that, still doing the same


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




ianripping[_63_]

Check to see if variable is duplicate.
 
its ok now, my syntax was incorrect, sorr

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



All times are GMT +1. The time now is 12:22 PM.

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