Apply VBA code to entire column

pea789

New Member
Joined
Oct 30, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I imagine that this is a super easy fix for those of you in the know but for a complete amature like me I am pulling my hair out. I want this code to be repeated in every column in row H. Any help would be much appreciated!

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Oldvalue As String

Dim Newvalue As String


Application.EnableEvents = True

On Error GoTo Exitsub




If Target.Address = "$H$2" 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 & vbNewLine & Newvalue

      Else:

  

      End If

    End If

  End If

End If

Application.EnableEvents = True

Exitsub:

Application.EnableEvents = True

End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Change this :
If target.value = $H$2 then

For below:
VBA Code:
If Target.Column = 8 Then
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,661
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top