I have code that checks for a string of data with in another string. I am new to Excel VB programming so I don't know if this is supposed to work or not. The string being checked does have the value of the search argument, however the Case does not happen. It is always going to the Case Else
Here is the code:
Sub assignColforSSNandAction()
Dim strPathFileName As String
Dim index2 As Integer
Dim iFirstRow As Long
Dim iLastRow As Long
iFirstRow = 1
'Get last Row that has data
iLastRow = Application.WorksheetFunction.CountA(Range("A:A"))
'Loop through SSN IFS worksheet to identify the folders and files that need to have SSN cleared
For index2 = iFirstRow To iLastRow
Range("A" & index2).Select
strPathFileName = ActiveCell.Text
If Dir(strPathFileName) <> "" Then
Select Case strPathFileName
Case (InStr(1, strPathFileName, "Not Matched", vbTextCompare) > 0)
Range("B" & index2).Select
ActiveCell.Text = "B"
Range("C" & index2).Select
ActiveCell.Text = "A"
Case (InStr(1, strPathFileName, "\Member", vbTextCompare) > 0)
Range("B" & index2).Select
ActiveCell.Text = "Q"
Range("C" & index2).Select
ActiveCell.Text = "B"
Case (InStr(1, strPathFileName, "MEDICAID", vbTextCompare) > 0)
Range("B" & index2).Select
ActiveCell.Text = "E"
Range("C" & index2).Select
ActiveCell.Text = "B"
Case (InStr(1, strPathFileName, "Primary", vbTextCompare) > 0)
Range("B" & index2).Select
ActiveCell.Text = "C"
Range("C" & index2).Select
ActiveCell.Text = "B"
Case (InStr(1, strPathFileName, "Supplemental", vbTextCompare) > 0)
Range("B" & index2).Select
ActiveCell.Text = "C"
Range("C" & index2).Select
ActiveCell.Text = "B"
Case Else:
Range("D" & index2).Activate
ActiveCell.Value = "Failed"
Range("E" & index2).Activate
ActiveCell.Value = "No Assignment of SSN/Action Column assigned: " + _
(strPathFileName)
' MsgBox "No Assignment of SSN/Action Column assigned: " + (strPathFileName), vbInformation
End Select
Else
Range("D" & index2).Activate
ActiveCell.Value = "Failed"
Range("E" & index2).Activate
ActiveCell.Value = "There is no file with this name: " + (strPathFileName)
End If
Next index2
MsgBox "SSN IFS Clean-up complete"
End Sub
Thanks for your replies!
Bookmarks