I have assigned variables as Integers and need to check that they are all positive decimal numbers. I know the command is IsNumber, but is there a way to check multiple variables without have a bunch of if statements? All the variables: coherencelength As Integer, tuningrange As Integer, power As Integer, sweeprate As Integer, kclockcount As Integer, kclockdepth As Integer need to be confirmed as positive decimals.
I know I could do this for each, but that would make the code very long and inefficient. Any help would be greatly appreciated.
If IsNumber(coherencelength.value) = True Then
Continue
Else
MsgBox coherencelength & " is not a positive decimal"
This is my code:
Sub columnlocation() ' identifies which column each parameter is in for Sheet1
Dim coherencelengcol As Integer, tunrangecol As Integer, averagepowercol As Integer, sweeprtecol As Integer, kclockctcol As Integer, kclockdepthcol As Integer
Dim coherencelength As Integer, tuningrange As Integer, power As Integer, sweeprate As Integer, kclockcount As Integer, kclockdepth As Integer
coherencelengcol = Application.Match("Coherence Length (mm)", Worksheets("Sheet1").Range("A1:Z1"), 0) ' Application.Match looks up the position of the value, 0 means its looking for an exact match case-sensitive
coherencelength = Worksheets("Sheet1").Cells(sysrow, coherencelengcol) ' assigning the data to a variable that will be used in updateWD
tunrangecol = Application.Match("Tuning Range (nm)", Worksheets("Sheet1").Range("A1:Z1"), 0)
tuningrange = Worksheets("Sheet1").Cells(sysrow, tunrangecol)
averagepowercol = Application.Match("Power (mW)", Worksheets("Sheet1").Range("A1:Z1"), 0)
power = Worksheets("Sheet1").Cells(sysrow, averagepowercol)
sweeprtecol = Application.Match("Sweep Rate (kHz)", Worksheets("Sheet1").Range("A1:Z1"), 0)
sweeprate = Worksheets("Sheet1").Cells(sysrow, sweeprtecol)
kclockctcol = Application.Match("K-Clock Count", Worksheets("Sheet1").Range("A1:Z1"), 0)
kclockcount = Worksheets("Sheet1").Cells(sysrow, kclockctcol)
kclockdepthcol = Application.Match("K-Clock set for Imaging Depth in air (mm)", Worksheets("Sheet1").Range("A1:Z1"), 0)
kclockdepth = Worksheets("Sheet1").Cells(sysrow, kclockdepthcol)
End Sub