If cell data entered changes value of another cell then run macro

NathanStadig

New Member
Joined
Feb 24, 2011
Messages
19
Thank-you for any assistance...

I have an excel spreadsheet where time is calculated.
If time out is entered in cell AA* then cell AC* in that row changes. What I want to do is if cell AC* is > than another cell (AQ1) then msg box appears. I want this to happen once data is entered in cell AA, not if cell AC is directly selected.

All I can figure out now is if cell AC* is selected.

Code I have so far which works great:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 29 And Target.Count = 1 Then Exit Sub
If Target > Range("$AQ$1") Then
    UserForm1.Show
Else:
    Exit Sub
End If
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 26 Or Target.Count > 1 Then Exit Sub
If Target > Range("$AQ$1") Then UserForm1.Show
End Sub
 
Upvote 0
Changed it to this code to reflect column AC being the data compared to "AQ1"

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 27 Or Target.Count > 1 Then Exit Sub
If Target.Offset(0, 2) > Range("$AQ$1") Then UserForm1.Show
End Sub
 
Upvote 0
Multiple Arguments: If cell data entered changes value of another cell then run macro

Now I'm trying to meet multiple criteria to show error messages.
Tried multiple If/ElseIf but couldn't get it to work.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  'Is Column 18 Selected?
If Target.Column <> 18 Or Target.Count > 1 Then Exit Sub
  'Once Data is inputted in Column 18 is it less than Column 17?
If Target.Offset(0, -1) > Target Then UserForm2.Show
  'Is Column 27 Selected?
If Target.Column <> 27 Or Target.Count > 1 Then Exit Sub
  'Once Data is inputted in Column 27 is Column 29 greater than 24 Hours?
If Target.Offset(0, 2) > Range("$AQ$1") Then UserForm1.Show
   
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Select Case Target.Column
    Case 18: If Target.Offset(0, -1) > Target Then UserForm2.Show
    Case 27: If Target.Offset(0, 2) > Range("$AQ$1") Then UserForm1.Show
End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,229
Messages
6,164,738
Members
451,911
Latest member
HMF009

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