Go to ActiveSheet.Range

excellence

Board Regular
Joined
Oct 5, 2005
Messages
155
Office Version
  1. 365
Platform
  1. MacOS
I can't seem to get this VBA to go to E15 !
Otherwise, it is fine.

Private Sub Worksheet_Calculate()
If Range("E24").Value > "1" Then
MsgBox "CLEAR"
ActiveSheet.Range("E15").Select
End If
End Sub

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Do you get the message box? Does it work if you remove the quotes?

VBA Code:
Private Sub Worksheet_Calculate()
If Range("E24").Value > 1 Then
MsgBox "CLEAR"
ActiveSheet.Range("E15").Select
End If
End Sub
 
Upvote 0
Jut replace first line with this:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Ha, Ha you're faster than me. :) I think he should added to the "change" not to calculate to execute that.
 
Last edited:
Upvote 0
Calculate is a strange one to use but if the OP presses F9 it should go to E15
Not sure if the OP wants it to execute when they change E24 or not (just changing the Sub line without defining a Target means it will fire on any cell change on the sheet, almost the same as using calculate), it would help if the OP stated exactly what they are trying to do.
 
Upvote 0
Do you get the message box? Does it work if you remove the quotes?

VBA Code:
Private Sub Worksheet_Calculate()
If Range("E24").Value > 1 Then
MsgBox "CLEAR"
ActiveSheet.Range("E15").Select
End If
End Sub
I got the message box, but still will not goto e15
 
Upvote 0
Are you triggering the calculate from the same sheet as the code is on and can you describe in words exactly what you are trying to do.

If you change the code to the code below does the 2nd message box give you what you expect?

VBA Code:
Private Sub Worksheet_Calculate()
    If Range("E24").Value > 1 Then
        MsgBox "CLEAR"
        MsgBox ActiveSheet.Parent.Name & " " & ActiveSheet.Name
        ActiveSheet.Range("E15").Select
    End If
End Sub
 
Upvote 0
Try
VBA Code:
Private Sub Worksheet_Calculate()
If Range("E24").Value > 1 Then
MsgBox "CLEAR"
ActiveSheet.Range("E15").Activate
End If
End Sub
 
Upvote 0
Calculate is a strange one to use but if the OP presses F9 it should go to E15
Not sure if the OP wants it to execute when they change E24 or not (just changing the Sub line without defining a Target means it will fire on any cell change on the sheet, almost the same as using calculate), it would help if the OP stated exactly what they are trying to do.
e24 is a countif formula to see if there are duplicates in a range in column D.
So, if there are duplicates the message box appears, I say OK and clear the duplicates with a macro.
Going to e15 would be the spot to reenter contents into column D if there was a duplicate and e15 contents would be added to column d via another macro.

I'll just forget about going to e15.
The RSVPs here are beyond my knowledge base.

A great deal of what I do with this is elementary, but works for me most of the time.
Thanks
 
Upvote 0
I would be trying to avoid using the Calculate event

e24 is a countif formula to see if there are duplicates in a range in column D.
I have assumed that range in column D is D15:D24 (edit the range in the code below as required) and used this Worksheet_Change code instead.
To test, remove any of the other event codes that may still be in the worksheet's code module.

BTW, is the worksheet 'Protected'?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("D15:D24")) Is Nothing Then
    If Range("E24").Value > 1 Then
      MsgBox "CLEAR"
      Range("E15").Select
    End If
  End If
End Sub

and e15 contents would be added to column d via another macro.
I suspect that your other macro may be affecting what is happening with the other suggestions here, including mine.
It would probably help clear things up if we saw that macro too.
 
Upvote 0
I would be trying to avoid using the Calculate event


I have assumed that range in column D is D15:D24 (edit the range in the code below as required) and used this Worksheet_Change code instead.
To test, remove any of the other event codes that may still be in the worksheet's code module.

BTW, is the worksheet 'Protected'?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("D15:D24")) Is Nothing Then
    If Range("E24").Value > 1 Then
      MsgBox "CLEAR"
      Range("E15").Select
    End If
  End If
End Sub


I suspect that your other macro may be affecting what is happening with the other suggestions here, including mine.
It would probably help clear things up if we saw that macro too.
Thanks for your help, but I have decided to forget the E15 and go with what I have. My knowledge base is too elementary.
I am not close to the level of knowledge here.

I apologize for any inconvenience.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,224,872
Messages
6,181,501
Members
453,047
Latest member
charlie_odd

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