VBA-Adding Text After Number Entry

bamaisgreat

Well-known Member
Joined
Jan 23, 2012
Messages
831
Office Version
  1. 365
Platform
  1. Windows
I have few cells B12, B18 AND B30 That i would like to enter in a number such as 50 into B12 and then it show 50-Extras Added.

Is this something that could be done?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Something like this in the worksheet code module seems to work:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B12, B18, B30")) Is Nothing Then
    Application.EnableEvents = False
    Target.Value = Target.Value & "-Extras Added"
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Hi,

Could you perhaps re-phrase exactly what you like to accomplish, I can't figure out what your requirements are.
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a value in B12, B18 or B30 and exit the cell.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B12,B18,B30")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    Target = Target & "-Extras Added"
    Application.EnableEvents = True
End Sub
 
Upvote 0
Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this VBA code in the resulting VB Editor window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim isect As Range
    Dim cell As Range
    
    Set isect = Intersect(Target, Range("B12:B12, B18:B18, B30:B30"))
    
    If Not isect Is Nothing Then
        Application.EnableEvents = False
        For Each cell In isect
            If cell <> "" Then cell = cell & "-Extras Added"
        Next cell
        Application.EnableEvents = True
    End If
    
End Sub
This should automatically do what you want.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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