Hi Guys,
Brief description of what i want my macros to achieve: I've trying to import data from two Excel spreadsheets, and then compare the data on each list to find the missing elements in each list and then highlight the data row if it is missing.
An issue i encounter when i press ImportButton2_Click. The spreadsheet i copied goes on to replace the "position" i import previously from pressing ImportButton1_Click. I wanted a clear order of which spreadsheet should come first when i import the documents. Any ideas how can i solve this problem?
Sorry if my information is not clear for you to understand. Thanks
Brief description of what i want my macros to achieve: I've trying to import data from two Excel spreadsheets, and then compare the data on each list to find the missing elements in each list and then highlight the data row if it is missing.
An issue i encounter when i press ImportButton2_Click. The spreadsheet i copied goes on to replace the "position" i import previously from pressing ImportButton1_Click. I wanted a clear order of which spreadsheet should come first when i import the documents. Any ideas how can i solve this problem?
Sorry if my information is not clear for you to understand. Thanks
Code:
Private Sub ImportButton1_Click()
Dim OpenFile As Variant
Dim FileName As String
CheckBoolean1 = True
If CheckBoolean2 = False Then
ComparisonButton.Enabled = False
ElseIf CheckBoolean1 = True And CheckBoolean2 = True Then
ComparisonButton.Enabled = True
End If
'-----------------------------------------------------------------------------
Dim Wkb1 As Workbook
Set Wkb1 = ActiveWorkbook
OpenFile = Application.GetOpenFilename( _
FileFilter:="Excel Files, *.xls; *.csv; *.xlsx", Title:="Importing Excel File 1")
If OpenFile = False Then
MsgBox "Please Select a Excel File"
Exit Sub
Else
Workbooks.Open OpenFile
End If
FileName = ActiveWorkbook.Name
Worksheets(1).Copy after:=Wkb1.Worksheets(1)
Workbooks(FileName).Close SaveChanges:=False
'-----------------------------------------------------------------------------
stringOfSheet1 = ActiveWorkbook.Name
End Sub
Private Sub ImportButton2_Click()
Dim OpenFile As Variant
Dim FileName As String
CheckBoolean2 = True
If CheckBoolean1 = False Then
ComparisonButton.Enabled = False
ElseIf CheckBoolean1 = True And CheckBoolean2 = True Then
ComparisonButton.Enabled = True
End If
'-------------------------------------------------------------------------------
Dim Wkb1 As Workbook
Set Wkb1 = ActiveWorkbook
OpenFile = Application.GetOpenFilename( _
FileFilter:="Excel Files, *.xls; *.csv; *.xlsx", Title:="Importing Excel File 2")
If OpenFile = False Then
MsgBox "Please Select a Excel File"
Exit Sub
Else
Workbooks.Open OpenFile
End If
FileName = ActiveWorkbook.Name
Worksheets(1).Copy after:=Wkb1.Worksheets(1)
Workbooks(FileName).Close SaveChanges:=False
'-------------------------------------------------------------------------------
stringOfSheet2 = ActiveWorkbook.Name
End Sub