![]() |
Mutiple comboboxes on user form
Hey everybody:
I am sort of new to this whole VBA thing and I am self teaching my self everything through the discussion groups so thank you all for writing different thing for us to read. the main reason for this post is that I am trying to make a spreadsheet that utilizes a user form to enter the data. I have never worked with combo boxes before and have two in my form. I have all the data in the drop downs - one has the date and the other has the time that we will be offering a certain service. I am trying to code something that would make it look at the spread sheet for the date selected and the time (both selected from dropdowns) but if the time was taken it shows an error message. If the date and time were both available it would then copy info from textboxes into the spreadsheet. here is what my code currently looks like: Private Sub Submit_Click() If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:00pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B5").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:20pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B6").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If End Sub --So what it is doing is just reading straight through everything and not doing each combo box time as specified. I hope this all makes since and someone can assist me! Thanks so much! ~Patrick |
Mutiple comboboxes on user form
Why don't you add messagebox like I show below to help you find the problem
Private Sub Submit_Click() msgbox("Combobox1 = " & Combobox1.value) msgbox("Combobox2 = " & Combobox2.value) If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:00pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B5").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If msgbox("Combobox1 = " & Combobox1.value) msgbox("Combobox2 = " & Combobox2.value) If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:20pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B6").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If End Sub "Eskimoblubber" wrote: Hey everybody: I am sort of new to this whole VBA thing and I am self teaching my self everything through the discussion groups so thank you all for writing different thing for us to read. the main reason for this post is that I am trying to make a spreadsheet that utilizes a user form to enter the data. I have never worked with combo boxes before and have two in my form. I have all the data in the drop downs - one has the date and the other has the time that we will be offering a certain service. I am trying to code something that would make it look at the spread sheet for the date selected and the time (both selected from dropdowns) but if the time was taken it shows an error message. If the date and time were both available it would then copy info from textboxes into the spreadsheet. here is what my code currently looks like: Private Sub Submit_Click() If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:00pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B5").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If If ComboBox1.Value = ("November 21st") And ComboBox2.Value = ("8:20pm") Then ActiveWorkbook.Sheets("November 21").Activate Range("B6").Select Private Sub Place_Info() If IsEmpty(ActiveCell) = False Then ActiveWorkbook.Sheets("Main").Activate Error.Show End If If IsEmpty(ActiveCell) = True Then ActiveCell.Value = TextBox1.Value ActiveCell.Offset(0, 1) = TextBox2.Value ActiveCell.Offset(0, 2) = TextBox3.Value ActiveCell.Offset(0, 3) = TextBox4.Value ActiveCell.Offset(0, 4) = TextBox5.Value ActiveCell.Offset(0, 5) = TextBox6.Value End If End Sub --So what it is doing is just reading straight through everything and not doing each combo box time as specified. I hope this all makes since and someone can assist me! Thanks so much! ~Patrick |
All times are GMT +1. The time now is 11:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com