Automatic update

Ron99

Active Member
Joined
Feb 10, 2010
Messages
347
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have this code

Sub status_update()
Dim COM As String
On Error GoTo veryEnd
If Range("E1").Text = P Then
COM = MsgBox("Update % Column")
veryEnd:
End If
End Sub

The above code works fine, but I have problem,

I want the code to give out the message automatically when the word P is entered in E1, rather than running the macro then getting a message.

Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Place your code into an Event Procedure, specifically the Worksheet_Change event (see here for more on event procedures: http://www.cpearson.com/excel/Events.aspx).

I would start your code with:
Code:
If Target.Address = "$E$1" and Target.Text = "P" Then
...
 
Upvote 0
Hi,

I am really sorry, I do not understand coding...

Can you please correct the same code and send it..

Thank you
 
Upvote 0
I was under the mistaken impression that you wrote the code.
As is written, I don't think it will work because you don't have quotes around the letter P.

In our to get this to wirk automatically, you must place the following code in a Sheet module instead of a Standard Module. In order to do this, just go to the page you would like to run it against. Then, right click on the Sheet tab name at the bottom of the screen and select "View Code". Then place this code in the resulting window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
    If Target.Count = 1 And Target.Address = "$E$1" Then
        If Target.Text = "P" Then
            MsgBox "Update % Column"
        End If
    End If
 
End Sub
Now this code will run anytime anyone manually types an upper case "P" in cell E1 on that sheet.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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