Hi guys,
I have a code and I am not sure how to add a popup message box to appear;
One if it cant find workbook 1 and another to say copy completed once it has copied over.
Please any help would be appreciated!
Thank you
The code I have is:
Sub CopyData()
Dim Wb1 As Workbook, wb2 As Workbook, wB As Workbook
Dim rngToCopy As Range
For Each wB In Application.Workbooks
If Left(wB.Name, 7) = "NHE_000" Or Left(wB.Name, 6) = "Period" Then
Set Wb1 = wB
Exit For
End If
Next
If Not Wb1 Is Nothing Then '<~~ check if you actually found the needed workbook
Set wb2 = ThisWorkbook
Wb1.Sheets("QRA").Visible = True
wb2.Sheets("Current").Range("A4:AG30").Copy
Wb1.Sheets("QRA").Range("A4").PasteSpecial Paste:=xlPasteValues, Paste:=xlPasteFormats
Application.CutCopyMode = False
Wb1.Sheets("QRA").Visible = xlSheetHidden
End If
End Sub
I have a code and I am not sure how to add a popup message box to appear;
One if it cant find workbook 1 and another to say copy completed once it has copied over.
Please any help would be appreciated!
Thank you
The code I have is:
Sub CopyData()
Dim Wb1 As Workbook, wb2 As Workbook, wB As Workbook
Dim rngToCopy As Range
For Each wB In Application.Workbooks
If Left(wB.Name, 7) = "NHE_000" Or Left(wB.Name, 6) = "Period" Then
Set Wb1 = wB
Exit For
End If
Next
If Not Wb1 Is Nothing Then '<~~ check if you actually found the needed workbook
Set wb2 = ThisWorkbook
Wb1.Sheets("QRA").Visible = True
wb2.Sheets("Current").Range("A4:AG30").Copy
Wb1.Sheets("QRA").Range("A4").PasteSpecial Paste:=xlPasteValues, Paste:=xlPasteFormats
Application.CutCopyMode = False
Wb1.Sheets("QRA").Visible = xlSheetHidden
End If
End Sub