Add Comboboxes On Userform At Run Time

May 7, 2009

I have a userform that has a text box. If user puts a number in it and click on proceed the userform must expand and display that many comboboxes. for e.g. if user inputs 8 and then click on proceed then there should be 8 comboboxes on the form. Is it possible to do?

View 4 Replies


ADVERTISEMENT

Two Comboboxes On A Userform

Jan 20, 2009

I have two comboboxes on a userform, they both get there list from the same formula. What I am trying to do is have the second combobox have it's selection preset based on the selection in combobox 1.

ie
Combobox1 = 6:00 AM
when you click on the dropdown for combobox2 i would like 6:00 AM to be the first selection possible, but I dont want it displayed in the box unless it is selected.

Dim timdat1(1 To 85)
For i = 1 To 85
timdat1(i) = Format(TimeSerial(5, (i + 1) * 15, 0) - Int(TimeSerial(5, (i + 1) * 15, 0)), "h:mm AM/PM")
Next i
combobox1.List = timdat1
combobox2.List = timdat1
i am at a loss for where to go from here

View 9 Replies View Related

Multiple Comboboxes In A Userform

Feb 17, 2007

I have a worksheet "Master Log" with a UserForm "UserForm2" set up that has 4 comboboxes and 2 text entries. I already have the filtered unique values for each combobox sent to columns "O" thru "R" and they are dynamic ranges. I have the code to populate one of the comboboxes in the userform but cant figure out how to modify the code to have all four populated without getting ambiguous entry errors. And also, do I have to initiate the form for each combobox? Below is the code Im using for a single combobox.

Private Sub UserForm_Initialize()
Dim MyUniqueList As Variant, i As Long
With Me.ListBox1
.Clear ' clear the listbox content
MyUniqueList = UniqueItemList(Range("o4:o100"), True)
For i = 1 To UBound(MyUniqueList)
.AddItem MyUniqueList(i)
Next i
.ListIndex = 0 ' select the first item
End With
End Sub


Private Function UniqueItemList(InputRange As Range, _
HorizontalList As Boolean) As Variant
Dim cl As Range, cUnique As New Collection, i As Long, uList() As Variant
Application.Volatile
On Error Resume Next
For Each cl In InputRange
If cl.Formula <> "" Then
cUnique.Add cl.Value, CStr(cl.Value)
End If
Next cl
UniqueItemList = ""
If cUnique.Count > 0 Then
Redim uList(1 To cUnique.Count)
For i = 1 To cUnique.Count
uList(i) = cUnique(i)
Next i
UniqueItemList = uList
If Not HorizontalList Then
UniqueItemList = _
Application.WorksheetFunction.Transpose(UniqueItemList)
End If
End If
On Error Goto 0
End Function

View 2 Replies View Related

How To Empty All Comboboxes And Textboxes In A Userform

May 3, 2009

I have a userform with many comboboxes and textboxes and I am using the following code to empty those controls:

View 9 Replies View Related

Userform To Use 2 Comboboxes To Hide Sheets

Jun 6, 2013

Let's say I have Sheet1-Sheet6. I also have combobox1 (with item 1, 2, & 3 as the list items) & combobox 2 (with items 1 & 2 as the list items).

If combobox1 = 1 & combobox2 = 1 then hide Sheets 2,3,4,5,6
if combobox1 = 1 & combobox2 = 2 then hide Sheets 1,2,4,5,6
If combobox1 = 1 & combobox2 = 3 then hide sheets 1,2,3,4,6
If combobox1 = 2 & combobox2 = 1 then hide sheets 1,3,4,5,6
If combobox1 = 2 & combobox2 = 2 then hide sheets 1,2,3,5,6
If combobox1 = 2 & combobox2 = 3 then hide sheets 1,2,3,4,5

I would like to also make both of these combo boxes required fields and to default text to say 'Select One...'

View 1 Replies View Related

Unusual Crashing Due To Userform Or Comboboxes

Jun 4, 2008

The spreadsheet is essentially a VBA GUI that validates information entered before writing it to a sheet in the workbook. There is a button on the first sheet that opens the GUI, and when the workbook is first used the GUI opens and runs fine. After adding a few rows using the GUI, saving the workbook, and then reopening it, attempting to open the GUI by clicking on the button will cause Excel to crash (and no errors are given). To compound the problem, it is not possible to find the issue by using the debugger, as the GUI runs fine as soon as VisualBasic is opened. I've tried to narrow it down by using MsgBoxes to find the approximate location where the form crashes, and it seems to happen when the .ListIndex property of a ComboBox is set inside the UserForm_Initialise method. I've played around for days trying to narrow it down further, removing .ListIndex statements as much as possible without breaking the entire thing.

View 2 Replies View Related

Ok Button To Control Comboboxes In Userform And Sheet

Feb 20, 2012

I Have a sheet with 4 activex comboboxes and 3 text boxes. If the right item is selected in the second combo box a user form opens up. That has 4 text boxes. It has a command button titled ok that takes the information from the 4 text boxes and puts them in a sheet called data.

Code:
Private Sub cmbOK_Click()
With Worksheets("Data").Range("A1")
.Offset(1, 8).Value = Me.txtFirm.Value

[Code]....

I need a way for the above code to run when the ok button on the user form is clicked.

View 7 Replies View Related

Dynamic 3 Deep Nested ComboBoxes On A UserForm

Jun 29, 2006

I have three ComboBoxes. I need the choice of the first ComboBox to detirmine what is shown in the second and the choice in the second to detirmine what is shown in the third. The lists will be growing as users add items.

View 2 Replies View Related

Series Of Dependent Comboboxes In Userform That Show Unique Values Of Dynamic Tables

Mar 23, 2014

This example workbook contains a datatable, which is inputted via a userform. The datatable has 4 columns: Date, Invoice no., Loads, Tonnage. This table is dynamic, as a new row gets entered each time data is entered in the userform. A different userform (the one in the example) has comboboxes which refer to the data in the table. This userform asks the user for the Date, Invoice no., Loads and Tonnage. I want to use comboboxes so that they will advise the input based on the users previous input.

The first combobox asks the user for a data, and should contain a list of all the unique dates that are stored in the table. When the first combobox is inputted, the list for the second combobox will change. The list of the second combobox should be a list of unique invoice numbers, based on the date that has already been entered. The 3rd and the 4th combobox should also show a list of unique values, based on the previously entered date and invoice no.

Example: The first combobox should advise the dates: 4-Nov-14 and 15-Nov-14. User chooses 4-Nov --> second combobox should advise unique invoice numbers based on chosen date: 1252 and 1311. User chooses 1152 --> 3rd combobox should advise unique values based on previous values: 3, 8 and 7. 4th combobox: 57, 23 and 47.

View 3 Replies View Related

Userform With Time Field Displays Time As Number

Dec 24, 2008

I have a userform that has a time field on it and then the userform displays the time as a number.

Ex. I entered 11:00 AM in the Time of Contact field and the form displays it as 0.458333333333333.

View 10 Replies View Related

Using Userform To Calculate Time To Sheet From Start Time?

Jun 19, 2014

I have a userform that time stamps on my userform as soon as i open the form, is there a way that when I submit, that the amount of time that I was on the call to be put in my column on my worksheet as minutes?

View 2 Replies View Related

Date/Time Formula: Pick Up A Date With Time Entry On A Worksheet And Place It Into A TextBox On A UserForm

Jun 17, 2006

I am attempting to pick up a date with time entry on a worksheet and place it into a TextBox on a UserForm. Format on the sheet is mm/dd/yyyy h:mm AM/PM. The UserForm is placing the value as mm/dd/yyyy 12:00 AM. here is the

Private Sub UserForm_Initialize()
If Not Range("dDate").Value = "" Then
TextBox2.Value = Range("dDate").Value
TextBox2.Text = Format(DateValue(TextBox2.Text), "mm/dd/yy h:mm AM/PM")
Else
TextBox2.Value = ""
TextBox2.SetFocus
End If
End Sub


"dDate" is the named range where the date is sitting. The format is also set on the TextBox2 exit event. Can anyone see why only the date portion is being transfered with the default 12:00 AM for no time component of the value?

View 3 Replies View Related

Userform Time Card

Dec 31, 2008

I am trying to put together a userform based time card calculator. User inputs the time in the time out and how long of a lunch. Then the program will display total hours worked for the day. Ive attached what I have so far. The only thing that is not very clear is that I have one hidden textbox for the lunch. It is there only for calculating and the visible one is going to inc by :15 min.

View 9 Replies View Related

Calculate Time From Userform?

Jul 14, 2010

I need to compute the total time in a userform.

I have a userform where:

1. User enters a start and end time Start1, End1 (23:00, 01:00)
2. The time difference is calculated and displayed in Total1 (2:00)
3. User enters Start2, End2 (22:00, 22:50)
4. Time difference calculated - display in Total2 (00:50)
5. Grand total of Total1, Total2 is displayed in GrandTotal (2:50)

The user will input the times as 0000 but I need to convert the entry into a time format. (User enters 1235 - I need it to covert to 12:35)

View 5 Replies View Related

Entering Time On Userform?

Nov 23, 2011

If I have 3 text boxes textbox1, textbox2 and textbox3

I want ot be able to enter a time in textbox1 and then a time in textbox2 and textbox3 would give the difference. i.e. 09:00 17:00 then textbox 3 would calculate 08:00

Then all 3 times would automaically be entered in Sheet1 A1,B1 and C1

View 9 Replies View Related

Add Controls To UserForm At Run-Time

Oct 25, 2006

I am trying to transfer data from a worksheet to a user form, so that the end users can edit the data on the user form, save it, and the revised data is sent back to the worksheet. since the worksheet data is dynamic, i am trying to dynamically add controls in the user form. but the form displays only one data.

Set sdel = Sheets("Deliverables")
Set rStartCell = sdel.Range("A65536").End(xlUp).Offset(0, 0)
counter = Mid(rStartCell.Address, 4)
dummy = 0
cnt = 1
'copy data from sheet to the user form
With sdel
'checking if deliverables sheet has any data
' If .Range("A3") <> " " Then Exit Sub
' MyTextBox.Caption = .Range("A3").Value
For r = 3 To counter
If .Cells(r, 1) <> "" Then

Set MyTextBox = Controls.Add("Forms.Label.1", "lbl" & cnt, Visible)
MyTextBox.Top = topadd + 30
MyTextBox.Left = 20
MyTextBox.Width = 150
MyTextBox = .Range("A" & r).Value
cnt = cnt + 1
Else
dummy = dummy + 1
End If
Next r

End With

View 3 Replies View Related

Formatting Userform Textbox To Time?

Jul 22, 2014

I have a timesheet, with a custom format of [h].mm. In my userform, I have a textbox which I would like to use to enter a time in, but when I run the macro, the time shows up correctly (such as 0.12 for 12 minutes), but it is still calculating as text. I've tried all the various codes I have found throughout the board but nothing has worked so far. I can get as far as making 0.12 minutes show as 12.12.00 AM, but then it shows the whole time instead of the 0.12 which the cell is formatted to do and does not calculate it at the bottom where I grab all the times from that column.

View 1 Replies View Related

UserForm - Only One Button Toggled At A Time

Dec 31, 2008

I have made a UserForm with 12 buttons on it to switch between 12 different Worksheets and I am attempting to have the button pressed down only when the sheet is active. The buttons all work fine and go to the right sheet, but will stay toggled when I click on a button for another sheet.

I have tried to create a seperate macro that makes all the ToggleButton.Value = False, but this just activates the ToggleButton_Click() macro each time and loops on and on. Is there a way to change the value of the toggle without initiating the click subroutine? Do I even want to use ToggleButton?

View 4 Replies View Related

Format All The TextBoxes On A UserForm The Same At One Time

Apr 1, 2009

I have 30+ Textboxes on the form.

In the process of entering data the textBoxes get different .BackColor settings.

When the reset command button is hit the boxes stay the same colors, so I could reset them with a single command rather than 30+ lines of formatting code.

View 7 Replies View Related

Convert Time To Minutes In Userform

Jul 14, 2009

I know how to do this in a worksheet: =(b1-a1)*1440. B1 being the end time and A1 being the start time. I have a userform where the start time and end time are entered in text boxes. txtstart1 and txtend1. I would like the result to show up in txtmin1. Here is my code that doesnt work. I tried to convert code from a non-time sheet of mine. Dim as Integer may be the problem, I just learn as I go, and so far have only dealt with Integers.

View 4 Replies View Related

Userform Textbox Calculations (time)

Feb 21, 2012

I've got a userform which I'm developing (my first) and I have two textboses:

Textbox6 = start time & Textbox7 = end time & Textbox10 which contains the calculation (Textbox7 - Textbox6).

Now I have code that works great for normal numbers however I need to be able to make the calculations in TIME (hence the start time / end time).

How I can amend this code to be able to calculate total time between textbox 7 and Textbox6.

Private Sub TextBox6_Change()

If TextBox6.Value = "" Then Exit Sub
If TextBox7.Value = "" Then Exit Sub
TextBox10.Value = CDbl(TextBox6.Value) - CDbl(TextBox7.Value)

[Code] .......

View 3 Replies View Related

Use Userform And Hidden Sheets At The Same Time

Feb 1, 2013

Is there a way to use a userform and hidden sheets at the same time?

I want to limit the access to the information through a userform but my userform requires me to unhide the userform to show. Is there a way to go around this? Because the information might be misused if the user can simply close the form and have access to the information in the sheet.

View 3 Replies View Related

Getting Run Time Error 91 - Stuck With UserForm

Aug 2, 2014

I'm getting a 'Run Time Error 91' saying that 'Object Variable or With Block not set'.

Error lies here:

Code:
Me.lstCategpry.Column = CustRec.GetRows(Fields:=Array("name"))
Userform Initialize:
Code:
Private Sub UserForm_Initialize()

[Code].....

View 4 Replies View Related

Creating A Time Zone Userform

Jul 29, 2008

I would like to add something to my workbook which, when called, gives you current time in Tokyo, Australia, USA, London, Europe (for example).

I am trying to work out what would be best.

Would it be possible to create this on the Status bar?

Alternatively, i guess a Userform shown as modeless (but i am not sure if the controls holding the times will update.

View 9 Replies View Related

Date And Time Picker On UserForm

Dec 24, 2008

I am trying to use the Date and Time Picker 6.0 and I have add it to the userform and named it DateofContact.

When I play the userform I get a error stating:

"Compile Error-Method or Data member not found"

Below I have added the code and it shows in red where the problem is.


Private Sub UserForm_Activate()

PSA.Text = Cells(lCurrentRow, 2).Value
cboTypeofContact.Text = Cells(lCurrentRow, 3).Value
DateofContact.Text = Cells(lCurrentRow, 4).Value
TimeofContact.Text = Cells(lCurrentRow, 5).Value
End Sub
I am not sure what to put in its place.

View 9 Replies View Related

Userform Date And Time Validation

Aug 1, 2006

I have several textboxes on a UserForm that must have both dates and times to calculate a time difference. I need a way to validate input to [mm/dd/yyyy hh:mm].

View 2 Replies View Related

Run Time Error When Calling Userform

Jan 16, 2007

I am getting a run time error # 9 when I run a macro that calls a Userform or when I try to run code in a Userform module. The code performs beautifully on my computer, but it did not work on a coworker's computer. It ended up working on 3 out of the 5 computers I have tried it on.

I have tried changing security settings to low, and a bunch of other stuff, but I cannot get the code to run on the computers that get the run time error on them when I try running the code on them.

I get the run time error when I try to load or show any userform in the workbook and I get it if I try to run code that is in the userform module. However, if I paste the code into a regular module and run it, the code runs fine.

Does anyone know what could be causing this? I don't think my code is causing the problem since it runs on some machines, I am guessing there is a setting that is preventing Excel from calling Userforms.

I have a button, Private Sub CommandButton1_Click, on a sheet that shows a userform. This is the bit of code that gets tagged with the run time error. The userform has a refedit control on it allows the user to select a cell and then hit ok to run the code or cancel to, well, cancel it.

Code for the button that gets tagged with the run time error:

Private Sub CommandButton1_Click()
frmLoadTrade.Show 'calls userform
End Sub

Code in the Userform Module:

Private Sub cmdCancel_Click()

TradeTicketSpreadsheetName = ThisWorkbook.Name
Unload Me
Workbooks(TradeTicketSpreadsheetName).Activate

End Sub

View 4 Replies View Related

Adding Code To A Userform At Run-time

May 27, 2007

The ultimate goal is to create a Userform at run-time.

The problem is writing event code for that Userform.

The current situation is:
I have a userform. (Created with the VBE, not at run-time.) There is one command button on that userform. The code module for that userform is this

Option Explicit ...

View 9 Replies View Related

Running Date And Time On Userform

May 30, 2007

Here is the code for my user form.

Private Sub UserForm_Initialize()

TextBoxDate.Value = Now
TextBoxDate = Format(TextBoxDate.Value, "dd mmmm yyyy hh:mm:ss")

End Sub

This is a form to have employees punch in/out. The form is designed to be running all the time. The TextboxDate is disableed so the user can not change it.

I would like to know if it is possible to get the time to be displayed on the form constantly? Right now it only updates when the OK button is pressed on the form.

View 9 Replies View Related

Using Picture And Caption In A Label On Userform At Same Time?

Mar 31, 2014

Is it possible to load an image into a label and have the caption for the label be visible too? I've only been successful having one or the other display but not both.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved