Option Explicit
Public Brr0412, Sh0412 As Worksheet, xR0412 As Range
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Resume Next
Sh0412.Activate
On Error GoTo 0
End Sub
'===============================
Private Sub Workbook_Open()
Call 置入輔助表_隱藏
Call 更新WEB資料
Call 比對_不同值變底色
End Sub
'===============================
Sub 置入輔助表_隱藏()
Application.DisplayAlerts = False
Set Sh0412 = ActiveSheet
Set xR0412 = Range(Sh0412.[A1], Sh0412.UsedRange): Brr0412 = xR0412
On Error Resume Next
Sheets("輔助表_WEB").Delete
On Error GoTo 0
With Sheets.Add
.Name = "輔助表_WEB"
.Visible = False
xR0412.Copy .[A1]
.UsedRange.ClearContents
.UsedRange = Brr0412
End With
End Sub
'===============================
Sub 比對_不同值變底色()
Dim Brr, xR As Range, i&, j%, xU As Range
Set xR = Range(Sh0412.[A1], Sh0412.UsedRange): Brr = xR
Set xU = Sh0412.[A1]
For i = 1 To UBound(Brr0412)
For j = 1 To UBound(Brr0412, 2)
If Brr(i, j) <> Brr0412(i, j) Then
Set xU = Union(xU, xR(i, j))
End If
Next
Next
xR.Interior.ColorIndex = xlNone
xU.Interior.ColorIndex = 6
Set xU = Nothing: Set xR = Nothing: Set xR0412 = Nothing
Erase Brr, Brr0412
End Sub
'===============================
Sub 更新WEB資料()
'請植入必須更新的程式碼
End Sub作者: coafort 時間: 2023-4-12 16:38