473,394 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

adding checkbox to message

1
Okay, I have looked everywhere and I'm sure it's very easy. I'm writing a program where I have to get alot of input from the user, instead of asking them one by one which parts apply to what they're doing I wanted to put a list of all the parts in a message box and they could check which ones apply. Is this at all possible to do in Excel VBA using code?
May 17 '07 #1
3 1199
MMcCarthy
14,534 Expert Mod 8TB
This question is being moved to the Visual basic forum.

ADMIN
May 17 '07 #2
Killer42
8,435 Expert 8TB
Thanks mmccarthy.

anp6, you will probably want to create a UserForm, in the VBA editor. I'm not experienced in this area, though. Perhaps someone else here can provide more info.
May 18 '07 #3
danp129
323 Expert 256MB
Okay, I have looked everywhere and I'm sure it's very easy. I'm writing a program where I have to get alot of input from the user, instead of asking them one by one which parts apply to what they're doing I wanted to put a list of all the parts in a message box and they could check which ones apply. Is this at all possible to do in Excel VBA using code?
I don't know forms very well but I made this (check for attachment):

Expand|Select|Wrap|Line Numbers
  1. 'Module code
  2. 'Comments:
  3. 'Add Userform and name it frmGetParts
  4. 'Add Microsoft Listview Control to toolbox and then add as name lvParts
  5. '... Set other properties to: Fullrowselect: True; LabelEdit: Manual; View: LvwReport
  6.  
  7. 'Add label named lblMsg
  8. 'Add command button called cmdOK, caption: OK
  9. 'Double click the OK button and add "Me.Hide" like this
  10. 'Private Sub cmdOk_Click()
  11. '    Me.Hide
  12. 'End Sub
  13.  
  14.  
  15. Option Explicit
  16. Sub TestMessageBox()
  17.     Dim wksPartsList As Worksheet
  18.     Dim oApplicableParts As Collection
  19.     Dim rngPartNos As Range
  20.     Dim iPart As Long
  21.     'sheet the part numbers are on
  22.     Set wksPartsList = Sheets("PartList")
  23.  
  24.     With wksPartsList
  25.         'range partnumbers are in (in a2:b2)
  26.         Set rngPartNos = .Range("a2:a" & .Range("a65536").End(xlUp).Row)
  27.     End With
  28.  
  29.     'Ask for user to select applicable parts
  30.     Set oApplicableParts = GetApplicableParts("Please select applicable parts:", rngPartNos)
  31.     For iPart = 1 To oApplicableParts.Count
  32.         MsgBox oApplicableParts.Item(iPart)
  33.     Next 'iPart
  34. End Sub
  35.  
  36. Function GetApplicableParts(sMessage As String, rngPartlist As Range) As Collection
  37.     'Function Returns items users check in the listview as a collection
  38.  
  39.     Dim rngPart As Range
  40.     Dim xItem As ListItem
  41.     Dim oSelected As New Collection
  42.  
  43.     With frmGetParts
  44.         'Set message of the window
  45.         .lblMsg = sMessage
  46.         'Add column "Part#" to lvParts
  47.         .lvParts.ColumnHeaders.Add , , "part#"
  48.         'Add column "Name" to lvParts
  49.         .lvParts.ColumnHeaders.Add , , "Name"
  50.         For Each rngPart In rngPartlist
  51.             'Add part# to lvParts
  52.             Set xItem = .lvParts.ListItems.Add(, , rngPart)
  53.             'Add part name to lvParts
  54.             xItem.ListSubItems.Add , , rngPart.Offset(0, 1)
  55.         Next 'rngPart
  56.         'Display the messagebox
  57.         .Show
  58.     End With
  59.  
  60.     For Each xItem In frmGetParts.lvParts.ListItems
  61.         'If item is checked add it to oSelected collection
  62.         If xItem.Checked = True Then oSelected.Add xItem.Text
  63.     Next 'xItem
  64.  
  65.     'Set this function to oSelected collection (thus making it return a collection of selected parts)
  66.     Set GetApplicableParts = oSelected
  67.     Set oSelected = Nothing
  68.     'Unload message window
  69.     Unload frmGetParts
  70. End Function
Attached Files
File Type: zip customMSG.zip (22.2 KB, 67 views)
May 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Robin | last post by:
I need to add a checkbox to the common dialog control for opening files. I know it is possible to customize the common dialog thru API. But the sample codes I have seen were too long and...
5
by: Craig Lister | last post by:
Newish to c# - Coming from Delphi. I'd like to add 255 checkboxes to a screen at runtime, and name then cb1, cb2... cb255 The code below does not work, but, how can I get this to work? public...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
19
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
4
tolkienarda
by: tolkienarda | last post by:
hi all I am working on a php driven database program for a literacy program, it will allow them to keep track of classes and students, the part i am strugling with is adding new classes, the...
5
by: Sansasoon | last post by:
Hi there, I am supposed to do a shop ... which I ve done so far. The only thing that I can't get working is adding up to get the result It would be really great if someone could help me (Sorry it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.