Sub 清單明細()
If ActiveCell.Cells.Column <> "4" Then Exit Sub
aa = ActiveCell
If aa = "" Then Exit Sub
g = Worksheets("清單明細").Cells(65536, 1).End(xlUp).Row
For i = 1 To g
If Worksheets("清單明細").Cells(i, 1) = aa Then
b = 0
For a = 4 To 34
kk(b) = Worksheets("清單明細").Cells(i, a)
b = b + 1
Next a
bb = Join(kk, ",")
'bb = Worksheets("清單明細").Cells(i, 3)
ActiveCell.Cells(, 4).Select
Exit For
End If
Next i
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=" & bb
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Dim bb, kk(30), aa
If ActiveCell.Cells.Column <> "4" Then Exit Sub
aa = ActiveCell
If aa = "Account Code " Then Exit Sub
If aa = "" Then Exit Sub
g = Worksheets("清單明細").Cells(65536, 2).End(xlUp).Row
For i = 1 To g
e = Worksheets("清單明細").Cells(i, 2)
If Worksheets("清單明細").Cells(i, 2) = aa Then
b = 0
j = Worksheets("清單明細").Cells(i, 34).End(xlToLeft).Column
For a = 3 To j
kk(b) = Worksheets("清單明細").Cells(i, a)
b = b + 1
Next a
bb = Join(kk, ",")
Exit For
End If
Next i
pp = Worksheets("清單明細").Cells(i, 3)
MsgBox pp, , "Account_Code說明"
ActiveCell.Cells(, 4).Select
ActiveCell = ""
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=bb
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = "You must enter a number from five to ten"
.ShowInput = True
.ShowError = True
End With
Set kk(30) = Nothing
ActiveCell.Offset(, -5) = Date
ActiveCell.Offset(, 1) = Environ("UserName")
End Sub作者: GBKEE 時間: 2012-1-16 20:29