Solved Select Full Column for VBA to work with (1 Viewer)

Universal_

New member
Local time
Today, 09:02
Joined
Aug 10, 2023
Messages
7
Afternoon All,

Hope this finds you all well, just having a moment and can't figure out how to code VBA in a way that the whole column on this sheet will make use of it.

This is the code I currently have written.

Private Sub Worksheet_Change(ByVal Target As Range)​
Dim Oldvalue As String​
Dim Newvalue As String​
On Error GoTo Exitsub​
If Target.Address = "$K$4" Then​
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then​
GoTo Exitsub​
Else: If Target.Value = "" Then GoTo Exitsub Else​
Application.EnableEvents = False​
Newvalue = Target.Value​
Application.Undo​
Oldvalue = Target.Value​
If Oldvalue = "" Then​
Target.Value = Newvalue​
Else​
If InStr(1, Oldvalue, Newvalue) = 0 Then​
Target.Value = Oldvalue & ". " & Newvalue​
Else:​
Target.Value = Oldvalue​
End If​
End If​
End If​
End If​
Application.EnableEvents = True​
Exitsub:​
Application.EnableEvents = True​
End Sub​

I know the issue is on this line "If Target.Address = "$K$4" Then"

What can I do to this to incorporate the whole column on this worksheet.

I have two cells ontop as part of a merged cell as a title but don't think that will cause issues.

Looking forward for your help.

All the best
 

cheekybuddha

AWF VIP
Local time
Today, 09:02
Joined
Jul 21, 2014
Messages
2,280
Something like:
Code:
If Target.Column = 11 Then
' ...

or:
Code:
If Not Intersect(Target, Range("K:K")) Is Nothing Then
' ...
 

Universal_

New member
Local time
Today, 09:02
Joined
Aug 10, 2023
Messages
7
Something like:
Code:
If Target.Column = 11 Then
' ...

or:
Code:
If Not Intersect(Target, Range("K:K")) Is Nothing Then
' ...
Total legend!

Thank you !
 
Last edited:

Users who are viewing this thread

Top Bottom