xenou
MrExcel MVP
- Joined
- Mar 2, 2007
- Messages
- 16,836
- Office Version
- 2019
- Platform
- Windows
Here's a bug that's got me crazy:
Note 1:
I tried changing the syntax to
rather than
This made no difference in the results shown in the immediate window.
Note2:
I've printed the condition with Debug.Print so I could see the value being tested and which block it runs through. Here's the immediate window:
As you can see, there are PICKUP DATE and TRACKING NUMBER are in the "case 2" block but they should have tested True for Case 1...
I've worked on this for 45 minutes...so any advice here would be much appreciated!!
Thanks for reading and looking at this with me
EDIT: Note3 - I also moved the UCase function out of the block to just make strTest = UCase(CStr(Cells(ROW_WITH_HEADERS, x).Value)) - also didn't help...which I am kind of glad it didn't because I don't need something else that wouldn't make sense!!
Note 1:
I tried changing the syntax to
Code:
Case "condition1", "condition2", "condition3"...
Code:
Case Is = "condition1","condition2", "condition3"...
This made no difference in the results shown in the immediate window.
Note2:
I've printed the condition with Debug.Print so I could see the value being tested and which block it runs through. Here's the immediate window:
Case 1: SENDER COMPANY NAME
Case 2: PICKUP DATE
Case 2: REFERENCE 1
Case 2: TRACKING NUMBER
As you can see, there are PICKUP DATE and TRACKING NUMBER are in the "case 2" block but they should have tested True for Case 1...
I've worked on this for 45 minutes...so any advice here would be much appreciated!!
Code:
'To hide or delete columns
For x = lCol To 1 Step -1
strTest = CStr(Cells(ROW_WITH_HEADERS, x).Value)
Select Case UCase(strTest)
Case Is = "TRACKING NUMBER", "PICKUP DATE", _
"SENDER COMPANY NAME", "SENDER ZIP", "RECEIVER CITY"
Debug.Print "Case 1: " & UCase(strTest)
Case Else
If Arg1 = "2" Then Columns(x).Delete
If Arg1 = "1" Then Columns(x).Hidden = True
Debug.Print "Case 2: " & UCase(strTest)
End Select
Next x
Thanks for reading and looking at this with me
EDIT: Note3 - I also moved the UCase function out of the block to just make strTest = UCase(CStr(Cells(ROW_WITH_HEADERS, x).Value)) - also didn't help...which I am kind of glad it didn't because I don't need something else that wouldn't make sense!!