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?
3 1199
This question is being moved to the Visual basic forum.
ADMIN
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.
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): - 'Module code
-
'Comments:
-
'Add Userform and name it frmGetParts
-
'Add Microsoft Listview Control to toolbox and then add as name lvParts
-
'... Set other properties to: Fullrowselect: True; LabelEdit: Manual; View: LvwReport
-
-
'Add label named lblMsg
-
'Add command button called cmdOK, caption: OK
-
'Double click the OK button and add "Me.Hide" like this
-
'Private Sub cmdOk_Click()
-
' Me.Hide
-
'End Sub
-
-
-
Option Explicit
-
Sub TestMessageBox()
-
Dim wksPartsList As Worksheet
-
Dim oApplicableParts As Collection
-
Dim rngPartNos As Range
-
Dim iPart As Long
-
'sheet the part numbers are on
-
Set wksPartsList = Sheets("PartList")
-
-
With wksPartsList
-
'range partnumbers are in (in a2:b2)
-
Set rngPartNos = .Range("a2:a" & .Range("a65536").End(xlUp).Row)
-
End With
-
-
'Ask for user to select applicable parts
-
Set oApplicableParts = GetApplicableParts("Please select applicable parts:", rngPartNos)
-
For iPart = 1 To oApplicableParts.Count
-
MsgBox oApplicableParts.Item(iPart)
-
Next 'iPart
-
End Sub
-
-
Function GetApplicableParts(sMessage As String, rngPartlist As Range) As Collection
-
'Function Returns items users check in the listview as a collection
-
-
Dim rngPart As Range
-
Dim xItem As ListItem
-
Dim oSelected As New Collection
-
-
With frmGetParts
-
'Set message of the window
-
.lblMsg = sMessage
-
'Add column "Part#" to lvParts
-
.lvParts.ColumnHeaders.Add , , "part#"
-
'Add column "Name" to lvParts
-
.lvParts.ColumnHeaders.Add , , "Name"
-
For Each rngPart In rngPartlist
-
'Add part# to lvParts
-
Set xItem = .lvParts.ListItems.Add(, , rngPart)
-
'Add part name to lvParts
-
xItem.ListSubItems.Add , , rngPart.Offset(0, 1)
-
Next 'rngPart
-
'Display the messagebox
-
.Show
-
End With
-
-
For Each xItem In frmGetParts.lvParts.ListItems
-
'If item is checked add it to oSelected collection
-
If xItem.Checked = True Then oSelected.Add xItem.Text
-
Next 'xItem
-
-
'Set this function to oSelected collection (thus making it return a collection of selected parts)
-
Set GetApplicableParts = oSelected
-
Set oSelected = Nothing
-
'Unload message window
-
Unload frmGetParts
-
End Function
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |