UserForm

hartless43

New Member
Joined
Dec 28, 2022
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Ok, I give up, so asking the experts. How do you call a UserForm based on a cell value from the WorkSheet_Change. Below is the one that want work.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("K14")) Is Nothing Then
       If Target.Value = 42 Then
          MG42.Show
        End If
    End If
End Sub

Thanks from an old man
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try replacing
VBA Code:
MG42.Show
with
VBA Code:
UserForm1.Show
 
Upvote 0
Why is that? UserForm1 is a generic name given to all forms. I have 6 more forms, but they are called from a Marco
 
Upvote 0
I assumed that "MG42" was the caption not the name for the userform. In a dummy file, I made sure that the userform name was "MG42" and your macro worked properly for me.
 
Upvote 0
Well, I assumed also, that if I had another Worksheet_change on this sheet my code would be (including the other WS-Change


VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'This keeps a running totla of all Mistakes
    Excel.Application.EnableEvents = False
    If [CurrentMistakes].Value > [PreviousMistakes].Value Then
        [TotalMistakes].Value = [TotalMistakes].Value + 1
    End If
    [PreviousMistakes].Value = [CurrentMistakes].Value
    Excel.Application.EnableEvents = True
        
    '/Private Sub Worksheet_Change(ByVal Target As Range) commented out
    If Not Intersect(Target, Range("K14")) Is Nothing Then
       If Target.Value = 42 Then
          MG42.Show
        End If
    End If
    
End Sub

Maybe those two don't work together

Jerry
 
Upvote 0
Try removing the other code and see if it works.
 
Upvote 0
I'll check that out later, gotta run for now, probably will be tomorrow...Going to Smoky Mountain Knife Works in Sevierville TN
 
Upvote 0
OK, Mumps, that does not work as you stated, but it works with a Macro. I have a Sudoku game and when I need a new puzzle to play, I select it from a bank of Solutions and they are numbered from 1 to 265 and puzzle 42 in that bank has 3 each 3x3 grids where the sum of each Row, Column, Diagonals = 15. As I copy a solution from the Bank to the game board, I have a macro that will create a puzzle by removing numbers and this is where I placed the code to show the UserForm if puzzle 42 is selected. So, thanks for your help and I will close this one out
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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