確認ボタンが付いたマクロを作成しています。つまり、既存のワークブック(メインマクロと同じシート)をアップロードします。重複がある場合はwb1とwb2のシートを比較し、最終的にメインマクロのシート上の重複した項目を強調表示します。これまでのところ、これは私の今のものですが、Set WorkLng1 = Wb1.Sharepoint.Range( "A" & Sharepoint.Rows.Count).End(xlUp).row部分で私が許可されていません。ここでは以下の私のコードは次のとおりです。ブックをメインマクロにアップロードし、重複してシートを比較します
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
私は上記の次の提案を試みたが、それは私にエラーが表示されます: WorkRng1 = Wb1.Sheets( "PRP Sharepoint")を設定します。範囲( "A"&Sharepoint.Rows.Count).End(xlUp).row Set WorkRng2 = wb2 .Sheets( "PRP Sharepoint")。範囲( "A"&Sharepoint.Rows.Count).End(xlUp).row – Sevpoint