Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If then VBScript issue

I'm trying to format some tables that I paste from qlikview in the export macro. I came up with the following script:

if CycleFlag = 1 then

'Light Brown'

XLDoc.Sheets(1).Range("A1:C22").Interior.Color = RGB(221,217,195)

'Grey'

XLDoc.Sheets(1).Range("D1:D22").Interior.Color = RGB(166,166,166)

else if CycleFlag = 2 then

'Light Brown'

XLDoc.Sheets(1).Range("A1:C62").Interior.Color = RGB(221,217,195)

'Grey'

XLDoc.Sheets(1).Range("D1:D62").Interior.Color = RGB(166,166,166)

end if

end sub

but I keep getting an error at the end sub line: "Expected 'If'". What am I doing wrong?

5 Replies
m_woolf
Master II
Master II

You don't show a sub at the beginning.

Sub SetColors()

You also don't show a definition for CycleFlag.

Anonymous
Not applicable
Author

I have a sub at the start of the submodule. I didn't pasted the code above the part of the script that might cause problems because that part is working fine.

Anonymous
Not applicable
Author

Apparently the problem was with the "else if" statement. I've corrected it and it's working

m_woolf
Master II
Master II

I don't see a problem in the script that you posted. Please post your entire script.

Anonymous
Not applicable
Author

I have managed to fix the issue by myself. I keep forgetting that VBA syntax isn't the same as VBScript syntax, despite being similar languages