I have the following code but its not working:
I'm trying to say if Per3 is blank, then check Per4, otherwise copy and paste the value into the specified region.
Then If Per4 is blank, then check Per5, otherwise copy and paste the value into the specified region.
Then If Per5 is blank, do nothing, otherwise copy and paste the value into the specified region.
Code:
Sub test()
Dim Per3 As String
Dim Per4 As String
Dim Per5 As String
Per3 = ThisWorkbook.Sheets("Diagnostics").Range("PerfCode3")
Per4 = ThisWorkbook.Sheets("Diagnostics").Range("PerfCode4")
Per5 = ThisWorkbook.Sheets("Diagnostics").Range("PerfCode5")
If Per3 <> "" Then
ThisWorkbook.Sheets("Diagnostics").Range("PerfCode3").Copy
ThisWorkbook.Sheets("Report").Range("PerTable1").PasteSpecial Paste:=xlPasteValues
ElseIf Per4 <> "" Then
ThisWorkbook.Sheets("Diagnostics").Range("PerfCode4").Copy
ThisWorkbook.Sheets("Report").Range("PerTable2").PasteSpecial Paste:=xlPasteValues
ElseIf Per5 <> "" Then
ThisWorkbook.Sheets("Diagnostics").Range("PerfCode5").Copy
ThisWorkbook.Sheets("Report").Range("PerTable3").PasteSpecial Paste:=xlPasteValues
Sheets("Report").Activate
Sheets("Report").Calculate
Sheets("Charts").Activate
Sheets("Charts").Calculate
End If
End Sub
Then If Per4 is blank, then check Per5, otherwise copy and paste the value into the specified region.
Then If Per5 is blank, do nothing, otherwise copy and paste the value into the specified region.