Hi all!
I have a little issue here. I'd like to insert a check if method with a warning message into my code, but can't get the desired result.
I'd like to check if the workbook exits, before it's opened and copied the sheet. If not I need a message and stop the whole process, else go on.
I've tried the 'if dir method = 0 or "" then --- else' but nothing. Determined the file and path but did nothing, only just placed a cmdbutton to the current sheet without the warning message.
My code:
This works fine, but I'd like to add a check method with a warning message.![]()
Sub Recall() Dim ws As Worksheet Dim wb As Workbook Dim filename As String On Error GoTo errorhandler Application.DisplayAlerts = False Set wb = Workbooks("Moulding check.xlsm") Set ws = ActiveSheet filename = ws.Range("C2") & " " & ws.Range("N2") Worksheets("Ures lap").Range("C2").ClearContents Worksheets("Ures lap").Range("N2").ClearContents Set closedBook = Workbooks.Open("H:\CD\01 Gyartaskozi ellenorzes\Lezart gyartasok\ " & filename & ".xlsx") closedBook.Sheets(filename).Copy Before:=ThisWorkbook.Sheets("Meretek") closedBook.Close SaveChanges:=False Kill ("H:\CD\01 Gyartaskozi ellenorzes\Lezart gyartasok\ " & filename & ".xlsx") wb.Activate ActiveSheet.Buttons.Add(650, 18, 110, 20).Select Selection.Name = "Gomb 1" Selection.OnAction = "SaveSheet" ActiveSheet.Shapes("Gomb 1").Select Selection.Characters.Text = "Munkalap mentese" Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select errorhandler: Resume Next Application.DisplayAlerts = True End Sub
Can someone help?
Thank you.
Bookmarks