Msg Box click ravages Button

gelu

Board Regular
Joined
Sep 30, 2022
Messages
85
Office Version
  1. 2021
Platform
  1. Windows
Hello everyone,

Something unexpected happens:

I click OK on a message box (of Checkbox1) which says ”Go to next step” (next step provided by ”Callout: Right Arrow 1” which hosts a hyperlink to the next worksheet)
I try to click on Next but it remains without reaction.

1665631959929.png


If I select any cell, or Save or do whatever and only then I click Next (on the Callout: Right Arrow 1) it works.

Can I put some code inside the CheckBox1_Click() so that on msg box exit it selects a cell? ... or how to get around this?

Thank you in advance,

G

PS: if the hyperlink is placed as text in a cell it works fine.



VBA Code:
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then Range("B1").Value = 1
If CheckBox1.Value = False Then Range("B1").Value = 0

If CLng(ActiveSheet.CheckBox1.Value) = True Then
    MsgBox "Succes!" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Go to next step"
    Exit Sub
End If
End Sub

Threads MR EXcel.xlsm
ABCDE
11
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20Next
21
22
23
24
25
26
27
28
29
Sheet1
 

Attachments

  • 1665631268317.png
    1665631268317.png
    8 KB · Views: 5

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Instead of requring the user to click a hyperlink, you could just put an Application.Goto after the user clicks OK.
 
Upvote 0
Solution
Thank you, Sir.

That would be wonderful.

I am new to VBA. Tried to follow the advice but I do smthg wrong:

VBA Code:
Private Sub CheckBox1_Click()

Dim ws As Worksheet
Set ws = Worksheets("Sheet3")

If CheckBox1.Value = True Then Range("B1").Value = 1
If CheckBox1.Value = False Then Range("B1").Value = 0

If CLng(ActiveSheet.CheckBox1.Value) = True Then
    MsgBox "Succes!" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Go to next step"
 
End If
Exit Sub

  Application.Goto ws

End Sub
 
Upvote 0
I've got it, thanks to your suggestion.

VBA Code:
Sub Next_Ws()
' https://stackoverflow.com/questions/72630800/go-to-a-referenced-cell-when-clicking-ok-in-the-message-box
    Dim Anchor As Range
    Set Anchor = ThisWorkbook.Worksheets("Sheet3").Range("A1")
    
    If Len(CStr(Anchor.Value)) = 0 Then
        MsgBox "Next Step" _
            & vbCrLf & vbCrLf & "Press OK to go to the next step.", vbOKOnly
        Application.Goto Anchor, True ' to not scroll, remove 'True'
        Exit Sub
    End If

End Sub

With the new solution I put a macro button and giveup the checkbox though (any way to keep the checkbox?)?
 
Upvote 0
Instead of requiring the user to click a hyperlink, you could just put an Application.Goto after the user clicks OK.
I've got it, thanks to your suggestion.

VBA Code:
Sub Next_Ws3()
' https://stackoverflow.com/questions/72630800/go-to-a-referenced-cell-when-clicking-ok-in-the-message-box
    Dim Anchor3 As Range
    Set Anchor3 = ThisWorkbook.Worksheets("Sheet3").Range("A1")
    
    If Len(CStr(Anchor3.Value)) = 0 Then
        MsgBox "Next Step" _
            & vbCrLf & vbCrLf & "Press OK to go to the next step.", vbOKOnly
        Application.Goto Anchor3, True ' to not scroll, remove 'True'
        Exit Sub
    End If

End Sub

With the new solution I put a macro button and giveup the checkbox though (any way to keep the checkbox?)?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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