Change value of a certain cell and will display or not a certain text in a range of cells

beapotz10

New Member
Joined
Jul 3, 2019
Messages
4
I really have never used vba before but i am really eager to nail this one.

What I want to happen is if I input "X" to cell E7, it will show the word same in a range of cells (ex: H1:H50) and if I delete the "X" on E7, the text will also be removed.

Please please help :rolleyes::rolleyes::rolleyes:
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Right click on the sheet tab. Press view code. In the 'white space' paste this:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range

Application.EnableEvents = False

Set rng = Intersect(Target, Range("E7"))

If Not rng Is Nothing Then
    If Len(rng.Value) > 0 Then
        Range("H1:H50") = rng.Value
    Else
        Range("H1:H50").ClearContents
    End If
End If

Application.EnableEvents = True

End Sub

See if that works for you.
 
Upvote 0
Well saving it isnt going to make any difference presuming of course you saved it with the code in place and the file is a macro enabled workbook with macros duly enabled. Check the code is still in the worksheet module.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

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