PDA

View Full Version : if condition is variable + number



stephanie.ma
06-27-2022, 09:54 AM
I am not sure the best way to ask this question, i imagine the answer is easy but I am not sure how to look it up online (I always try that first). it is possible it is working and I am just not realizing it. I was just testing up to the end of the case statement so maybe I would not see the math until after the case statement

I want an if statement that says

if slidenumber = startnumber + 3 then....

the trouble is that it keeps saying that Slidenumber = startnumber and does not want to add the 3

(side note: this if is part of a case statement that there are 22 options...so need to be able to say +3. then the next conditions would say +4)


Below is a little bit of my actual code. it seems the 'math' portion of the ifthen conditions is not working


If SN = SiteSlidesStart Then
FN = "Alaska Slide 1"
ElseIf SN = SiteSlidesStart + 1 Then
FN = "Alaska Slide 2"
ElseIf SN = SiteSlidesStart + 2 Then
FN = "ABQ Slide 1"
ElseIf SN = SiteSlidesStart + 3 Then
FN = "ABQ Slide 2"
EndIf

stephanie.ma
06-27-2022, 10:07 AM
nevermind, it works fine. I just did not try the code after the case statement (which is where I would see the different slide numbers)

Paul_Hossler
06-27-2022, 10:15 AM
1. I changed your HTML tags to CODE tags (the # icon) and formatted it a little

2. Hard to tell without seeing the entire macro, but I'd use Select Case instead since I vaguely recall that there's a limit on how many If Then ElseIf's you can have





Select Case SN
Case SiteSlidesStart
FN = "Alaska Slide 1"

Case SlidesStart + 1
FN = "Alaska Slide 2"

Case SiteSlidesStart + 2
FN = "ABQ Slide 1"

Case SiteSlidesStart + 3
FN = "ABQ Slide 2"

.....

End Select