ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compare 2 mem variables against a string value (https://www.excelbanter.com/excel-programming/438126-compare-2-mem-variables-against-string-value.html)

Ron5440

compare 2 mem variables against a string value
 
Hey,
Can anyone help here...

If Mdl = "ZDX" Then 'Works fine
If Mdl or Mdl2 = "ZDX" Then 'Generates Type mismatch error

Does anyone know how to check more than one memory variable (Mdl and Mdl2)
against a string value?

Thanks,
RR


Paul C

compare 2 mem variables against a string value
 
Try this

If Mdl="ZDX" or Mdl2 = "ZDX" Then
--
If this helps, please remember to click yes.


"Ron5440" wrote:

Hey,
Can anyone help here...

If Mdl = "ZDX" Then 'Works fine
If Mdl or Mdl2 = "ZDX" Then 'Generates Type mismatch error

Does anyone know how to check more than one memory variable (Mdl and Mdl2)
against a string value?

Thanks,
RR


Mike H

compare 2 mem variables against a string value
 
Hi,

The correct syntax is

If Mdl = "ZDX" Or Mdl2 = "ZDX" Then

Mike

"Ron5440" wrote:

Hey,
Can anyone help here...

If Mdl = "ZDX" Then 'Works fine
If Mdl or Mdl2 = "ZDX" Then 'Generates Type mismatch error

Does anyone know how to check more than one memory variable (Mdl and Mdl2)
against a string value?

Thanks,
RR


Ryan H

compare 2 mem variables against a string value
 
I made this same mistake when I was beginning to learn VBA. This is the way
to do it:

If Mdl = "ZDX" OR Mdl = "ZDX" Then
' do something
End if

Hope this helps! If so, click "YES" below.
--
Cheers,
Ryan


"Ron5440" wrote:

Hey,
Can anyone help here...

If Mdl = "ZDX" Then 'Works fine
If Mdl or Mdl2 = "ZDX" Then 'Generates Type mismatch error

Does anyone know how to check more than one memory variable (Mdl and Mdl2)
against a string value?

Thanks,
RR



All times are GMT +1. The time now is 08:25 AM.

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