Hi,
I have a problem when I try to open a new Excel workbook with a VBA macro. I have the followin gcode
***********************************************
Dim fd As FileDialog 'compare check
Dim selectedfile As Variant
Dim this_FullName, compare_FullName As String
Dim this_FileName, compare_FileName As String
Dim this_Workbook, compare_Workbook As Workbook
this_FullName = ThisWorkbook.FullName
this_FileName = Dir(this_FullName)
Set this_Workbook = Workbooks(this_FileName)
this_Workbook.Activate
' -------------------------------------------------------
' select file to compare with
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
If .Show = -1 Then
For Each selectedfile In .SelectedItems
compare_FullName = selectedfile
Next selectedfile
Else
End If
End With
' ------------------------------------------------------
Set fd = Nothing
compare_FileName = Dir(compare_FullName)
Workbooks.Open fileName:=compare_FullName
Set compare_Workbook = Workbooks(compare_FileName)
this_Workbook.Activate
'Here I want to move data between the two workbooks
End Sub
****************************************************
It opens the selected file but then it starts the sub routine all over again without moving the data.
Any ideas?
Best Regards
Stefan
Bookmarks