Hi, so I have the below code which opens a source file and then copies and pastes the data in to the original file. I need to change it to so that if the cell (B3) is empty then the macro stops, without errors. I need it to continue as it does if the file name/path in B3 isn't found.
Any help much appreciated
Dim ExtFile As String
Dim ExtBk As Workbook
ExtFile = Range("B3").Value
If Not ExtFile = "" And Dir(ExtFile) <> "" Then
Else
ExtFile = Application.GetOpenFilename(FileFilter:="microsoft excel files (*.xls), *.xls", Title:="Please Select A File")
End If
On Error Resume Next
Set ExtBk = Workbooks(Dir(ExtFile))
On Error GoTo 0
If ExtBk Is Nothing Then
Application.Workbooks.Open ExtFile
Set ExtBk = Workbooks(Dir(ExtFile))
End If
'TO HERE OPENS THE FIRST FILE
Worksheets("database").Select
Sheets("Database").UsedRange.Select
Selection.Copy
' select current workbook and paste the values starting at A1
Windows("14.03 Portfolio Rollup Basic.xlsm").Activate
Worksheets("Project 1").Select
Sheets("Project 1").Range("A1").Select
Worksheets("Project 1").Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormat
Any help much appreciated
Dim ExtFile As String
Dim ExtBk As Workbook
ExtFile = Range("B3").Value
If Not ExtFile = "" And Dir(ExtFile) <> "" Then
Else
ExtFile = Application.GetOpenFilename(FileFilter:="microsoft excel files (*.xls), *.xls", Title:="Please Select A File")
End If
On Error Resume Next
Set ExtBk = Workbooks(Dir(ExtFile))
On Error GoTo 0
If ExtBk Is Nothing Then
Application.Workbooks.Open ExtFile
Set ExtBk = Workbooks(Dir(ExtFile))
End If
'TO HERE OPENS THE FIRST FILE
Worksheets("database").Select
Sheets("Database").UsedRange.Select
Selection.Copy
' select current workbook and paste the values starting at A1
Windows("14.03 Portfolio Rollup Basic.xlsm").Activate
Worksheets("Project 1").Select
Sheets("Project 1").Range("A1").Select
Worksheets("Project 1").Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormat