標題:
關於VBA
[打印本頁]
作者:
sheau-lan
時間:
2014-12-24 08:54
標題:
關於VBA
說明於夾帶擋內
作者:
owen06
時間:
2014-12-24 10:47
回復
1#
sheau-lan
在SHEET1貼上試試
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 99
Dim TG As Range
With Target
If .Row >= 3 And .Column = 1 Then
If .Value = "" Then
.Offset(0, 2) = ""
.Offset(0, 3) = ""
.Offset(0, 5) = ""
.Offset(0, 6) = ""
Else: Set TG = Sheet3.[H3:H9999].Find("*" & .Value & "*", , , xlWhole)
.Offset(0, 2) = TG.Offset(0, -6).Value
TG2 = .Offset(0, 2).Value
.Offset(0, 3) = TG.Offset(0, -3).Value
.Offset(0, 5) = Application.VLookup(TG2, Sheet2.[A4:E9999], 5, False)
.Offset(0, 6) = TG.Offset(0, 1).Value
End If
End If
End With
99
End Sub
複製代碼
作者:
GBKEE
時間:
2014-12-24 11:05
回復
1#
sheau-lan
[attach]19923[/attach]
作者:
sheau-lan
時間:
2014-12-24 11:14
可以用..真是太感激了
可是客戶樣品區如果沒有東西會跑出#N/A
可已讓他空白嗎?
作者:
owen06
時間:
2014-12-24 11:26
回復
4#
sheau-lan
這樣呢?
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 99
Dim TG As Range
With Target
If .Row >= 3 And .Column = 1 Then
If .Value = "" Then
98: .Offset(0, 2) = ""
.Offset(0, 3) = ""
.Offset(0, 5) = ""
.Offset(0, 6) = ""
Else: Set TG = Sheet3.[H3:H9999].Find("*" & .Value & "*", , , xlWhole)
If TG Is Nothing Then GoTo 98
.Offset(0, 2) = TG.Offset(0, -6).Value
TG2 = .Offset(0, 2).Value
.Offset(0, 3) = TG.Offset(0, -3).Value
.Offset(0, 5) = Application.VLookup(TG2, Sheet2.[A4:E9999], 5, False)
If IsError(.Offset(0, 5).Value) Then .Offset(0, 5) = ""
.Offset(0, 6) = TG.Offset(0, 1).Value
End If
End If
End With
99
End Sub
複製代碼
作者:
sheau-lan
時間:
2014-12-24 11:29
GBKEE大品號在圖面明細裡喔
owen06 大已經有幫我解決囉!!
謝謝你喔!!
作者:
sheau-lan
時間:
2014-12-24 11:32
owen06大
可以用囉!!
而且快多了..不會一直重算儲存格
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)