I have this code which works fine;
However if I change it so that the ' is removed from the 4 lines, it fails to print if cell E2 contains "Print".
The contents of cell E2 is a vlookup that may or may not return "print" - is this the problem perhaps?
TIA
Code:
Sub LoopthroughDataValidation()
Dim rCell As Range
Dim Data As Range
Dim a As Range
Set a = Range("A2")
If MsgBox("Are you sure you want to print/email ALL payslips?", vbYesNo) = vbYes Then
For Each rCell In Range("Performers")
a.Value = rCell.Value
'If Sheets("Pay Advice").Range("E2") = "print" Then
Range("Payslip").PrintOut
'ElseIf Sheets("Pay Advice").Range("E2") = "print only" Then
'Range("Payslip").PrintOut
'End If
'EMAIL CODE
Next rCell
Else
End If
End Sub
However if I change it so that the ' is removed from the 4 lines, it fails to print if cell E2 contains "Print".
Code:
Sub LoopthroughDataValidation()
Dim rCell As Range
Dim Data As Range
Dim a As Range
Set a = Range("A2")
If MsgBox("Are you sure you want to print/email ALL payslips?", vbYesNo) = vbYes Then
For Each rCell In Range("Performers")
a.Value = rCell.Value
If Sheets("Pay Advice").Range("E2") = "print" Then
Range("Payslip").PrintOut
ElseIf Sheets("Pay Advice").Range("E2") = "print only" Then
Range("Payslip").PrintOut
End If
'EMAIL CODE
Next rCell
Else
End If
End Sub
The contents of cell E2 is a vlookup that may or may not return "print" - is this the problem perhaps?
TIA