TxMarine1014
Technical User
I am getting an error of Case without Select Case and I do not know why. I have used code similar to this in some previous Macros, so I would assume that it would work unfortunately it did not. Just a little background on to what I am trying to do:
I have two Worksheets that I am working with, and I am trying to total up the information and write it on to my acutal report that is mentioned in the Macro as "Montly Exception Report.xlsx". Any help would be great!
Do While Cells(n, 1) <> Empty
TXMSG = ActiveSheet.Cells(n, 5).Value 'saves value as plannned cost
TMRPA = ActiveSheet.Cells(n, 8).Value 'saves value as planned cost
TOT = ActiveSheet.Cells(n, 7).Value 'saves value as Counter
If TXMSG = XMSG Then
If TMRPA = MRPA Then
mtot = mtot + TOT
Else:
Windows("Monthly Exception Message Report.xlsx").Activate
Select Case MRPA
Case "3301"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
If TMRPA = "3301/SAREP" Then
y = y + 1
Else
If TMRPA = "3301/SRVIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
Else
If TMRPA = "3301/UNSIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
End If
Windows("LMP Exception Report.xlsm").Activate
Case "3301/SAREP"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
If TMRPA = "3301/SRVIS" Then
y = y + 1
Else
If TMRPA = "3301/UNSIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
End If
Windows("LMP Exception Report.xlsm").Activate
Case "3301/SERVIS"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
y = y + 1
Windows("LMP Exception Report.xlsm").Activate
End If
End Select
Else
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
y = 3
Z = Z + 1
Windows("LMP Exception Report.xlsm").Activate
End If
n = n + 1
Loop
I have two Worksheets that I am working with, and I am trying to total up the information and write it on to my acutal report that is mentioned in the Macro as "Montly Exception Report.xlsx". Any help would be great!
Do While Cells(n, 1) <> Empty
TXMSG = ActiveSheet.Cells(n, 5).Value 'saves value as plannned cost
TMRPA = ActiveSheet.Cells(n, 8).Value 'saves value as planned cost
TOT = ActiveSheet.Cells(n, 7).Value 'saves value as Counter
If TXMSG = XMSG Then
If TMRPA = MRPA Then
mtot = mtot + TOT
Else:
Windows("Monthly Exception Message Report.xlsx").Activate
Select Case MRPA
Case "3301"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
If TMRPA = "3301/SAREP" Then
y = y + 1
Else
If TMRPA = "3301/SRVIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
Else
If TMRPA = "3301/UNSIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
End If
Windows("LMP Exception Report.xlsm").Activate
Case "3301/SAREP"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
If TMRPA = "3301/SRVIS" Then
y = y + 1
Else
If TMRPA = "3301/UNSIS" Then
y = y + 1
ActiveSheet.Cells(x, y) = 0
y = y + 1
End If
Windows("LMP Exception Report.xlsm").Activate
Case "3301/SERVIS"
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
y = y + 1
Windows("LMP Exception Report.xlsm").Activate
End If
End Select
Else
Sheet = Sheets(Z).Select
ActiveSheet.Cells(x, y) = mtot
mtot = TOT
y = 3
Z = Z + 1
Windows("LMP Exception Report.xlsm").Activate
End If
n = n + 1
Loop