Run UserForm When Linked Cell Is Empty

pwebley

Board Regular
Joined
Mar 2, 2011
Messages
69
I have a userform that appears as soon as my workbook is open and it requires that you enter your first and last name. It then dumps the name into a linked cell. I need help making that userform reappear if the contents of the linked cell are deleted or if it is empty. Any help will be appreciated.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
What's the address of the linked cell? You could use the Worksheet_Change event procedure, test if it's blank and, if so, show your UserForm.
 
Upvote 0
On "ThisWorkbook" I have:

Private Sub Workbook_Open()
userform1.TextBox1.SetFocus
userform1.Show
End Sub

When I click submit this is what happens:

Private Sub CommandButton1_Click()
If TextBox1.Value = "" Then
MsgBox "Please enter your name in the text field"
Me.TextBox1.SetFocus
Else
Range("C2").Value = userform1.TextBox1.Text
userform1.Hide
End If
End Sub

Where would I put "Worksheet_Change event procedure?" I appreciate your help.
 
Upvote 0
This is what I put in my Module1:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target(2, 3) = "" Then
useform1.Show
End If
End Sub

A box keeps appearing that prompts me to select a macro name. Not sure how to get this to work.
 
Upvote 0
[Code:]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1") = "" Then
UserForm1.Show
End If
End Sub
[/Code]
 
Upvote 0
Thanks for the help, however, it still asks for a macro name when I attempt to run it. I have several macros in the workbook and a list of them appears but I do not want them associated with this feature. Is this code supposed to be in Module1 of the workbook? All of the macros in Module1 begin with "Sub" while this code begins with "Private Sub." Thanks for your help. Sorry I need so much help.
 
Upvote 0
Is it?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$C$2" Then Exit Sub
    If Target.Value = "" Then
        userform1.Show
    End If
End Sub
 
Upvote 0
This is what is in there:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C2") = "" Then
UserForm1.Show
End If
End Sub

I changed it to what you just showed and it still prompted me for a macro. I fear this is a very simple fix and that perhaps I haven't communicated my objective properly.
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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