Solved

excel form checkboxes

Posted on 2014-03-23
6
239 Views
Last Modified: 2014-03-24
hello all,

is there a faster way in vba to add multiple check-boxes in a form in excel? the checkbox names could be checkbox1,checkbox2,checkbox3.....etc

i have create 35 checkboxes within a form and then do the same for other forms as well...so this is kind of pain

Thank you
0
Comment
Question by:Rayne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 39949656
Do you mean a userform or a form on a worksheet?

For a userform you could use something like this.
Private Sub UserForm_Initialize()
Dim chk As MSForms.Checkbox
Dim lngTop As Long

    lngTop = 5

    For I = 1 To 35
        Set chk = Me.Controls.Add("Forms.CheckBox.1, "CheckBox" & I)
        chk.Top = lngTop
        lngTop = lngTop+chk.Height+5
    Next I

End Sub

Open in new window

That puts all the checkboxes in one column which might not be suitable but the code can be refined to place them in some other configuration.

Similar code can be created if the form is on a sheet.

By the way, you could use a listbox with MultiSelect set to fmMultiSelectMulti and ListStyle set to fmListStyleOption.

That would show a chekcbox next to each item in the listbox.
0
 

Author Comment

by:Rayne
ID: 39949682
Thank you Imnorie, that is awesome
how can use the listbox - how can i populate the list box with data set from one column in worksheet - please assist
0
 

Author Comment

by:Rayne
ID: 39949693
so the question is > how do i add a set of vlaues in a worksheet to that awesome list box you mentioned? I am not able to populate the listbox so far..

Thank you
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:Rayne
ID: 39949699
you are awesome imnorie, you saved me a huge chunk of time - listbox rocks, checkboxes not.....thank you thank you , i got it :)
0
 
LVL 34

Expert Comment

by:Norie
ID: 39950169
I take it you figured out the listbox?

If you didn't here's a simple example that populates a listbox from A2:A35 on Sheet1 and sets it up to display checkboxes.
Private Sub UserForm_Initialize()

    With Me.ListBox1
        .List = Sheets("Sheet1").Range("A2:A35").Value
        .ListStyle = fmListStyleOption
        .MultiSelect = fmMultiSelectMulti
    End With

End Sub

Open in new window

0
 

Author Comment

by:Rayne
ID: 39950669
Thank you Imnorie,

This is Perfection to the ULTIMATE, thank you, thank you :)
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question