FAQ Database Discussion Community


VBA - Adding a listbox to an array

arrays,vba,listbox,userform
I've been searching around online, and just want to know how to add a bunch of ListBoxes from my Userform to my array. Here's what I have so far: Dim LBArray() As Variant Private Sub UserForm_Initialize() ReDim LBArray(7) As Variant FirstNameTextBox.Clear LastNameTextBox.Clear HotelCIDate.Clear HotelCODate.Clear HotelNameBox.Clear HotelConfStatus.Clear HotelConfNumber.Clear LBArray(0) = FirstNameTextBox...

Userform activating the sheet where it was initiated first

excel,vba,excel-vba,userform
I have a userform with few buttons for different macros to run. At the end of execution of macro it hides the userfrom. I have resablled the close button of userform with the following code: Private Sub UserForm_QueryClose _ (Cancel As Integer, CloseMode As Integer) ' Prevents use of the...

Userform in VBA macro is closing the entire excel file

excel,vba,excel-vba,userform
I created a UserForm with several functions. The form opens as I open the Excel file, however if I try to close the form the Excel file close together. Additionally, I can't open the VBA of this Excel (containing the form), so what I do (and that is really dum)...

Loop to Create Option buttons in a Userform not working

vba,userform,optionbutton
I need to create several option buttons in a Userform (each one for a array element). Am I missing something here? Cause it returns an error.. DefaultTop = 60 For X = 0 To UBound(ArrPlants) Set Jonas(x) = SAPPlants.Controls.Add("Forms.optionbutton.1", Y, True) 'Error on the above line ^^^ With Jonas(x) .Top...

Excel Userform Textbox Constant Set Focus

excel,vba,excel-vba,listbox,userform
First of all I would like to thank all of you guys. Maybe you did not notice but you help me to grasp VBA to some level from scratch. I am still in learning process so I may be missing something really simple, please be gentle :) First of all...

Populating a ListBox from search criteria entered into a TextBox in Excel VBA

excel,vba,excel-vba,listbox,userform
I have posted this problem before, however, I think it was overly complicated and I didn’t explain it very well. This time I am just using a simple UserForm as an example. I want to populate a ListBox by entering search criteria in a Textbox. I have three columns: Column...

Populate Userform combobox from a given range on a mac (excel 2011)

excel,combobox,populate,userform
How do you populate a combobox with values from a given range on a mac. I have been searching for answers for the last hour but none of the solutions seem to be working. I have a userform called Details and a combobox called CurrencyList that I would like to...

Populate Userform textbox based on cell selected by Combox

excel,vba,combobox,textbox,userform
In my excel document I have the following information in two columns: US Dollar (USD) 1 British Pound (GBP) 0.63 Guatemalan Quetzal (GTQ) 0.13 Honduras Lempira (HNL) 0.046 Other Please give factor Other Please give factor Other Please give factor Other Please give factor I have a combobox that is...

Combobox on userform populating only after cancelling first attempt

excel-vba,combobox,userform
I have a piece of code in a module: UserForm1.Show UserForm1.ComboBox1.clear UserForm1.ComboBox2.clear UserForm1.ComboBox1.List = Array("xxxxxxx", "xfdshthr", "tyetrert") The user runs this code to bring up a userform with 2 comboboxes, the second of which needs to be cleared after the user has entered a new value in the first. Bizarrely...

Excel VBA - Filter on ComboBox does not recognise first value

excel-vba,filter,combobox,userform
I have a userform set up which contains a ComboBox. The ComboBox is populated with values which are pulled from a range of cells which have been defined in the Name Manager (range of A1:A5 stored in a separate sheet.) The default caption for ComboBox is "Select Office" On the...

How to fire click event on already-selected OptionButton in Excel Userform

vba,excel-vba,radio-button,userform,optionbutton
I read somewhere that once an option button (or radio button) is selected on a UserForm, click events are not registered. Is this true? If so, what are some good ways around this, aside from using checkboxes instead? Thanks! UPDATE: Per user3561813's suggestion, I tried the MouseUp event with the...

Comparing Excel cell values and a userform Textbox

excel,vba,excel-vba,cell,userform
Ok, the problem is that im working in a excel userform, but i cannot find a way to do a comparation between a textbox value and a cell value and if some statement is meet it will write other value to another textbox (the program is has already been made...

Using VBA, How to Create CheckBox in a UserForm passing the RecordSet Fields

excel,vba,dynamic,checkbox,userform
I have Command Button which is required to show a User Form Dynamically as Below, with the Column Headers fetched from a Record Set as a Check Box Option. The Code that I Have for Initialize is as below Private Sub UserForm_Initialize() Set xl1 = Excel.Application Dim xlXML As Object...

RE-show previous Userform

excel-vba,userform,private-methods
i have a series of userforms that will run in sequence, and i need a button that can RE-show the previous userform, i've tried the code below but it gives a error telling me that this userform has already been show, i'm clueless about how to get this done, here...

VBA Dialog box to select range in different workbook hanging up

excel,vba,excel-vba,userform
I used the code that was responded with in the link I have attached below and I am having some problems can you please help me? VBA Dialog box to select range in different workbook When I click on the refedit box to be able to select the range I...

Excel - Open a named userform

excel-vba,userform
Sure this is very basic, I had userforms that I had not named and I called these by using UserForm1.Show. Now I have named these eg. ProgressBar. I call this one by UserForms.Add("ProgressBar").Show vbModeless But i cant figure out how to make this bit work: Private Sub UserForm_Initialize() 'With UserForms("ProgressBar")...

Excel VBA keep Listbox from workbook persistent after sourse is closed

vba,userform
I have a listbox on a userform that I am populating from an external workbook. If I keep the source spreadsheet open the listbox dispays correctly. When I close the external workbook the listbox seems no longer displays correctly and if you scroll the listbox text is replaced with a...

Userform called Userform TextBox Control behavior

excel,vba,excel-vba,userform
So I have an excel workbook that opens userform1 on the workbook open event. Once certain conditions are met on userform1 it calls a procedure that loads and shows userform2. Userform2 has a label, a textbox and a button. This issue I have is that the events for the textbox...

VBA : Runtime Error 9 - Seems it can't find Public Function in the same UserForm code module

vba,excel-vba,userform
Here is the code for the UserForm that I'm building, everything run smoothly with a test Array. I'm looking for partial match with the public function GetMatchingArt, which is fine on his own, to add an OptionButton for each match. But when I try to call this function in the...

Userform controls - looping and checking value

loops,excel-vba,controls,togglebutton,userform
I am trying to loop through two sets of controls on a userform. If a combination of two controls (togglebuttons) are true then do something. The sub is called from the userform where the controls are created. This is the first time I've used the userform control variable, the code...

Change User Form Page in VBA Form

excel,vba,excel-vba,userform,multipage
Good morning! I have an User Form in VBA Excel with multiple Pages. I want to create a command button ("Next" button) that allow the user to change the page. What code should I use? ...

How to update a userform label once range selected via refedit

excel,vba,excel-vba,userform
I have a userform with 2 refedit boxes. They both allow the user to select a cell. I have a label underneath each refedit that i would like to show the text of a specific cell on that row (not necessarily the selected cell), I guess it would be something...

VBA - UserForm with multiples TextBoxes in infinite calculation loop

vba,excel-vba,textbox,infinite-loop,userform
I have an UserForm with 5 TextBoxes, and each time one is updated I recalculate the others. But how do I avoid a "infinite loop" as the first will recalculate second which will recalculate the first and so on... Here is a part of my UserForm's code, only the TextBox_Change(s)...

1004 error using combox selections to update a dataset

excel,vba,excel-vba,userform
I have a userform with which the user can use command buttons to scroll through the data, some of which is displayed in text boxes. I have a 2 comboboxes, one dependent on the other, which use case statements. I want to use these combobox selections to update the original...

Userform listbox rowsource not populating

excel,excel-vba,listbox,userform
I have a userform with an OK and Cancel button and a listbox. It is supposed to populate using this code: Private Sub UserForm_Initialize() Me.StartUpPosition = 0 Me.Top = Application.Top + (Application.Height / 2) - (Me.Height / 2) Me.Left = Application.Left + (Application.Width / 2) - (Me.Width / 2) With...

VBA UserForm - Best way to use a TextBox as a decimal numerical input, independently of regional settings?

vba,excel-vba,userform
I developed an UserForm to ease DataBase inputs for one of my projects. In this UF, there is a TextBox dedicated to a numerical value. I use this code to avoid text entries : Private Sub TextBox1_Change() If Right(Me.TextBox1.Value, 1) = "." Or Right(Me.TextBox1.Value, 1) = "," Or _ Right(Me.TextBox1.Value,...

VBA - UserForm - How to restore default Label caption while loaded

vba,userform
I created an UserForm, and I'm updating a lot of things on the ComboBox_Change event, including some Labels' caption using this : Me.Lab_LastVal.Caption = Replace(Me.Lab_LastVal.Caption, "Currency", Me.ComboBox1.Value) Me.Lab_NewVal.Caption = Replace(Me.Lab_NewVal.Caption, "Currency", Me.ComboBox1.Value) The problem is that when I do it once, it won't work because Currency will have disappeared of...

VBA - Trapping events on dynamically created Textbox

excel,vba,excel-vba,events,userform
I am writing a VBA application in Excel. I have a Userform that dynamically builds itself based upon the data contained in one of the worksheets. All of the code that creates the various comboboxes, textboxes and labels is working. I created a class module to trap OnChange events for...

How to make User Form Output at the end of a column in Excel VBA

excel,vba,user-interface,excel-vba,userform
I'm trying to make this user form output option button results at the end of a column. Originally I tried using the same i in the for next loop that I have in my main module, but the user form wouldn't recognize the variable, even after dimensioning it as public....

How to fix run time error 424 when accessing the value of a CheckBox in Excel VBA?

excel-vba,error-handling,userform
Okay so here is the problem: In my user form, I have 2 checkboxes. I want to be able to use the value of the checkbox to perform a certain job. Example: Sub main() UserForm1.Show If UserForm1.CheckBox1.Value=True Then MsgBox("Awesome") End If End Sub Now my problem with this is that...

Center alignment within a Frame

excel,vba,excel-vba,userform
I would like to know how I can horizontally align to center textboxes and labels inside a Frame in VBA. Basically, I want each text box to be placed at the center of the Frame with the corresponding label next to it.

Need to open a userform with combobox lists but with values already selected

excel,excel-vba,combobox,userform
I have a userform that works fine. Now I need to edit some values I selected using the userform,so I want to open the userform with the values already selected. I already have the userform that saves the values in some sheets, I try to open the same userform but...