嗨,我需要獲取單元格的文本列作爲操作。使用vba獲取特定文本的單元格列號
我現在的代碼如下。
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim actionColName As String
If Target.Count > 1 Then GoTo exitHandler
On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler
If rngDV Is Nothing Then GoTo exitHandler
If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 3 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& "+ " & newVal
End If
End If
End If
End If
exitHandler:
Application.EnableEvents = True
End Sub
在上面的代碼有如下的條件 如果Target.Column = 3然後
而不是硬編碼與3的值我想應用此邏輯爲含有完整的列值ACTION在該列的其中一個單元格中。
你能請張貼我已經發布了樣本文件 – brettdj 2013-03-18 11:22:37
(第一)列? – user1668653 2013-03-20 05:28:34
哪裏是示例文件示例文件 – brettdj 2013-03-20 06:23:00