Creating a userform that lets me select the Client I want?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I want to make a userform that fills in the number of clients i have and lets me choose which one i want to use?

So I can make the userform pop up etc. so lets just concentrat on what i want
I have 10 text boxes linked to 10 cells, if any cell is empty I want that text box to be hidden
so
I want a bit of code that says if Cell A10 is "" then text box 10 Not visible

if you can help me with this that would be great

Thank you

Tony
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Re: Help Creating a userform that lets me select the Client I want?

This code will work when you first show the userform and will also work when the userform is showing and you delete or show values in the Controlsource Cells in the Worksheets.


Try something like in sheet Module:-
Code:
Private [COLOR="Navy"]Sub[/COLOR] CommandButton1_Click()
UserForm1.Show vbModeless
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Private [COLOR="Navy"]Sub[/COLOR] Worksheet_Change(ByVal Target [COLOR="Navy"]As[/COLOR] Range)
[COLOR="Navy"]If[/COLOR] Target.Count = 1 [COLOR="Navy"]Then[/COLOR]
    Call UserForm1.test(Target)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

Paste this in Userform Module (At top of module):-
Code:
Option Explicit
[COLOR="Navy"]Sub[/COLOR] test(r [COLOR="Navy"]As[/COLOR] Range)
[COLOR="Navy"]Dim[/COLOR] Ctrl [COLOR="Navy"]As[/COLOR] Control, t
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Ctrl [COLOR="Navy"]In[/COLOR] Me.Controls
   [COLOR="Navy"]If[/COLOR] TypeName(Ctrl) = "TextBox" [COLOR="Navy"]Then[/COLOR]
     [COLOR="Navy"]If[/COLOR] UCase(Ctrl.ControlSource) = UCase(r.Address(0, 0)) [COLOR="Navy"]Then[/COLOR]
        [COLOR="Navy"]If[/COLOR] Ctrl.Value = "" [COLOR="Navy"]Then[/COLOR]
           Ctrl.Visible = False
        [COLOR="Navy"]Else[/COLOR]
            Ctrl.Visible = True
        [COLOR="Navy"]End[/COLOR] If
     [COLOR="Navy"]End[/COLOR] If
  [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Ctrl
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

Private [COLOR="Navy"]Sub[/COLOR] UserForm_Initialize()
[COLOR="Navy"]Dim[/COLOR] Ctrl [COLOR="Navy"]As[/COLOR] Control
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Ctrl [COLOR="Navy"]In[/COLOR] Me.Controls
    [COLOR="Navy"]If[/COLOR] TypeName(Ctrl) = "TextBox" [COLOR="Navy"]Then[/COLOR]
        Ctrl.Visible = True
            [COLOR="Navy"]If[/COLOR] Ctrl.Value = "" [COLOR="Navy"]Then[/COLOR]
                Ctrl.Visible = False
            [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Ctrl
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0
Re: Help Creating a userform that lets me select the Client I want?

Wow, thank you this is excellent.
thank you very much

Tony
 
Upvote 0
Re: Help Creating a userform that lets me select the Client I want?

You're welcome
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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