I am creating a macro that will have a verify button. Which means, I will upload an existing workbook (same sheets with the main macro). And I need to compare the wb1 and wb2 sheets if there are any duplicates and will eventually highlight the duplicate item on the sheet of main macro. So far this is what I have now but it doesn't allow me on the Set WorkRng1 = Wb1.Sharepoint.Range("A" & Sharepoint.Rows.Count).End(xlUp).row part. Here is my code below:
Sub UploadandCompareSheets()
Dim Wb1 As Workbook
Dim wb2 As Workbook
Dim MainPage As Worksheet
Set MainPage = Sheets("Main")
Dim tbl As ListObject
Dim ws1 As Worksheet
Dim Sharepoint As Worksheet
Set Sharepoint = Sheets("PRP Sharepoint")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a File", _
filefilter:="Excel File *.xlsx (*.xlsx),")
If FileToOpen = False Then
MsgBox "No File Specified.", vbExclamation, "ERROR"
Exit Sub
Else
Set wb2 = Workbooks.Open(Filename:=FileToOpen)
For Each sheet In wb2.Sheets
If sheet.Visible = True Then
Dim WorkRng1 As Range, WorkRng2 As Range, Rng1 As Range, Rng2 As Range
Set WorkRng1 = Wb1.Sharepoint.Range("A" & Sharepoint.Rows.Count).End(xlUp).row
Set WorkRng2 = wb2.Sharepoint.Range("A" & Sharepoint.Rows.Count).End(xlUp).row
For Each Rng1 In WorkRng1
rng1Value = Rng1.value
For Each Rng2 In WorkRng2
If rng1Value = Rng2.value Then
Rng1.Interior.Color = VBA.RGB(255, 0, 0)
Exit For
End If
Next
Next
End If
Next sheet
End If
End Sub