Column Contents

Sal1

New Member
Joined
Apr 15, 2009
Messages
34
I would like to create a macro that does the following. Due to the fact that I can’t record these types of steps, I was wondering if I could get some help.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p> </o:p>
Every time a cell in Column D contains NEW1 or OLD1, I would like “Customer” to be entered into Column G in the same row.
<o:p> </o:p>
Every time a cell in Column D contains OLD2, I would like “Assets” to be entered into Column G in the same row.
<o:p> </o:p>
Every time a cell in Column D contains NEW2, I would like Column G in the same row to contain “ShortTerm”
<o:p> </o:p>
Every time a cell in Column D contains OLD3, I would like Column G in the same row to contain “LongTerm”
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hello and welcome to MrExcel.

Right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim s As String
If Target.Column = 4 Then
    Select Case (UCase(Target.Value))
        Case "NEW1", "OLD1": s = "Customer"
        Case "OLD2": s = "Assets"
        Case "NEW2": s = "Short Term"
        Case "OLD3": s = "Long Term"
    End Select
    If s <> "" Then Target.Offset(, 3).Value = s
End If
End Sub
 
Upvote 0
Thank you. I appreciate very much your help. Perhaps it’s my error but the code keeps asking for this part “If Target.Column = 4 Then” of the code to be debugged. Any thoughts?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 
Upvote 0
I changed this line0 “Private Sub Worksheet_Change(ByVal Target As Range)”, otherwise I was not able to see it and run it when I pressed (Alt F8)
 
Upvote 0
Please change it back to the exact code that I posted. Then go back to your sheet and enter one of your values in column D. Column G will populate automatically.
 
Upvote 0
You are right. You are right. My mistake. I am sorry. Thank you very much for your help! This works very well.
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,317
Members
448,564
Latest member
ED38

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