標題:
[發問]
請問我想做個上下產品的比對應該怎麼寫
[打印本頁]
作者:
et010884
時間:
2013-12-10 14:58
標題:
請問我想做個上下產品的比對應該怎麼寫
各位大大好 如題 由於客戶 廠商繁多 每個人需求又不一樣 常常因為輸入錯誤名稱導致生產錯誤
懇請大大幫忙指導一下 當下比對不一樣時可以跳出視窗提醒 並將底色更換
作者:
kimbal
時間:
2013-12-10 23:52
各位大大好 如題 由於客戶 廠商繁多 每個人需求又不一樣 常常因為輸入錯誤名稱導致生產錯誤
懇請大大幫忙指 ...
et010884 發表於 2013-12-10 14:58
那個位置與那個位置比對?
作者:
luhpro
時間:
2013-12-11 00:09
各位大大好 如題 由於客戶 廠商繁多 每個人需求又不一樣 常常因為輸入錯誤名稱導致生產錯誤
懇請大大幫忙指 ...
et010884 發表於 2013-12-10 14:58
以下程式放在 ThisWorkBook 內
Private Sub Workbook_Open()
Dim lRow&
Set dD = CreateObject("Scripting.Dictionary")
lRow = 3
With Sheets("工作表1")
Do While .Cells(lRow, 2) <> ""
If .Cells(lRow, 3) <> "" Then
If dD(CStr(.Cells(lRow, 2))) = "" Then
dD(CStr(.Cells(lRow, 2))) = CStr(.Cells(lRow, 3))
Else
If dD(CStr(.Cells(lRow, 2))) <> .Cells(lRow, 3) Then
.Cells(lRow, 3).Interior.ColorIndex = 37
MsgBox ("比對錯誤")
End If
End If
Else
.Cells(lRow, 3).Interior.ColorIndex = 37
MsgBox ("沒有產品名稱")
End If
lRow = lRow + 1
Loop
End With
End Sub
複製代碼
以下程式放在 Module 內
Public dD
複製代碼
以下程式放在 Sheet1 內
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 Then
With Target
If (.Column = 2 Or .Column = 3) And .Offset(, 2 - .Column) <> "" And .Offset(, 3 - .Column) <> "" Then
If dD(CStr(.Offset(, 2 - .Column))) <> .Offset(, 3 - .Column) Then
.Interior.ColorIndex = 37
MsgBox ("輸入錯誤")
.Select
Else
.Interior.ColorIndex = -4142
End If
End If
End With
End If
End Sub
複製代碼
[attach]17037[/attach]
作者:
et010884
時間:
2013-12-11 09:57
回復
3#
luhpro
謝謝大大
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)