Concatenate shows the second and third value except the first value - excel

I have this macro that concatenates values from 3 cells, the problem is that it only concatenates the 1st and 2nd values, before it only concatenated the the first value was 3, the second value was march and the third value was 2015, so the result just gives me " 3march"
this is my code:
Private Sub CommandButton1_Click()
Sheets("Info").Activate
Range("M2:Q2").Select
Selection.Copy
Range("A2").Cells(1).Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
Loop
Selection.Offset(0, 12).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.Offset(0, -12).Select
Selection.Cells(1).Select
'ahora viene la parte de pegar los valores,,,
Selection.Cells(1).Value = TextBox1.Value
Selection.Cells(1, 2).Value = ComboBox1.Value
Selection.Cells(1, 3).Value = ComboBox4.Value
Selection.Cells(1, 4).Value = ComboBox5.Value
Selection.Cells(1, 5).Value = ComboBox6.Value
Selection.Cells(1, 6).Value = ComboBox9.Value
Selection.Cells(1, 7).Value = ComboBox13.Value
Selection.Cells(1, 8).Value = TextBox3.Value
Selection.Cells(1, 9).Value = TextBox4.Value
Selection.Cells(1, 10).Value = TextBox8.Value
Selection.Cells(1, 11).Value = TextBox6.Value
Selection.Cells(1, 12).Value = ComboBox12.Value
'HERE IS THE PROBLEM!!!!!!
f_env = Selection.Cells(1, 3).Value & "-" & Selection.Cells(1, 4).Value & "-" & Selection.Cells(1, 5).Value
Selection.Cells(1, 17).Value = f_env
Unload UserForm1
End Sub

Because the column (on the selection's row) is actually determined by the column that selection was in, you will get a date in column Q only if selection is in column A. That may be a minor point but I believe the destination should always be a certain column.
    
Sub gather_date()
Dim sel As Range
With Selection.Parent
For Each sel In Selection.Columns(1).Cells
If Application.CountA(sel.Resize(1, 3)) = 3 Then
.Cells(sel.Row, 17) = CDate(Join(Array(sel.Value2, Left(sel.Offset(0, 1).Value2, 3), sel.Offset(0, 2).Value2), "-"))
.Cells(sel.Row, 17).NumberFormat = "d-mmmm-yyyy"
End If
Next sel
End With
End Sub
Since you are usig a macro based upon select, I've added a loop that will process all of the cells in selection.
This could also be performed with the following worksheet formula in Q2.
=DATEVALUE(CONCATENATE(B2, "-", C2, "-", D2))
Format as a date and fill down as necessary.

Edit:
Added new code.
It is hard to run the code as nobody but you has the workbook, and we would have to try and reproduce the workbook ourselves. Here is a revised code as I have interpreted what you are trying to do. I cannot test it as I don't have your workbook.
Private Sub CommandButton1_Click()
Dim sh As Worksheet
Dim Crng As Range 'copy range
Dim LrWs As Long 'last row
Dim Prng As Range 'paste range
Dim Drng As Range
Dim f_env As String
Set sh = Worksheets("Info")
With sh
Set Crng = .Range("M2:Q2")
LrWs = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
Set Prng = .Cells(LrWs, 13)
Crng.Copy
Prng.PasteSpecial xlPasteAll
Application.CutCopyMode = 0
Set Drng = .Cells(LrWs, 1)
Drng.Value = TextBox1.Value
Drng.Offset(0, 1).Value = ComboBox1.Value
Drng.Offset(0, 2).Value = ComboBox4.Value
Drng.Offset(0, 3).Value = ComboBox5.Value
Drng.Offset(0, 4).Value = ComboBox6.Value
Drng.Offset(0, 5).Value = ComboBox9.Value
Drng.Offset(0, 6).Value = ComboBox13.Value
Drng.Offset(0, 7).Value = TextBox3.Value
Drng.Offset(0, 8).Value = TextBox4.Value
Drng.Offset(0, 9).Value = TextBox8.Value
Drng.Offset(0, 10).Value = TextBox6.Value
Drng.Offset(0, 11).Value = ComboBox12.Value
End With
f_env = ComboBox4.Value & "-" & ComboBox5.Value & "-" & ComboBox6.Value
Drng.Offset(0, 16) = f_env
End Sub
Link us up to a sample workbook, if you can't get this working properly.

Related

Excel/VBA Summary sheet - overwriting data

first of all a thank you for previous help! You learned me more and still am learning everyday to code better :)
In the previous posts I wrote about having a userform for some input. Then it searches for the persons name in all the sheets in the workbook and writes the data as specified. In my workbook I would like to dedicate 1 sheet to summarize from all other sheets.
Now here is where an error occurs. The data is written down on the summary sheet, but when I select another name, the first row (lRow, 3) gets re-written.
I think that my mistake occurs with the lastrow statement. I have tried the .Range("C"...) version to find the last used row. Now it also finds the last used row, but also somehow overwrites the first row with values other then the selected name
Dim lRow As Long
Dim Ws As Worksheet
Dim Naam As String
Dim xTo As String
Dim xBCC As String
With Me.ComboBox1
i = .ListIndex
If i < 0 Then
MsgBox "Er is niemand geselecteerd.", vbExclamation
Exit Sub
End If
xTo = .List(i, 1)
xBCC = .List(i, 2)
Naam = .List(i, 3)
End With
Set Ws = Worksheets(ComboBox1.Value)
lRow = Ws.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
With Ws
.Cells(lRow, 3).Value = Format(Date, "DD-MM-YYYY") & " " & Format(Time, "HH:MM")
If chk1.Value Then .Cells(lRow, 5).Value = 1
If chk1.Value = False Then .Cells(lRow, 5).Value = 0
If chk2.Value Then .Cells(lRow, 6).Value = 1
If chk2.Value = False Then .Cells(lRow, 6).Value = 0
If chk3.Value Then .Cells(lRow, 7).Value = 1
If chk3.Value = False Then .Cells(lRow, 7).Value = 0
If chk4.Value Then .Cells(lRow, 8).Value = 1
If chk4.Value = False Then .Cells(lRow, 8).Value = 0
If chk5.Value Then .Cells(lRow, 9).Value = 1
If chk5.Value = False Then .Cells(lRow, 9).Value = 0
If chk6.Value Then .Cells(lRow, 10).Value = 1
If chk6.Value = False Then .Cells(lRow, 10).Value = 0
If chk7.Value Then .Cells(lRow, 11).Value = 1
If chk7.Value = False Then .Cells(lRow, 11).Value = 0
If chk8.Value Then .Cells(lRow, 12).Value = 1
If chk8.Value = False Then .Cells(lRow, 12).Value = 0
If chk9.Value Then .Cells(lRow, 13).Value = 1
If chk9.Value = False Then .Cells(lRow, 13).Value = 0
If 10.Value Then .Cells(lRow, 14).Value = 1
If 10.Value = False Then .Cells(lRow, 14).Value = 0
If chk11.Value Then .Cells(lRow, 15).Value = 1
If chk11.Value = False Then .Cells(lRow, 15).Value = 0
If chk12.Value Then .Cells(lRow, 16).Value = 1
If chk12.Value = False Then .Cells(lRow, 16).Value = 0
If chk13.Value Then .Cells(lRow, 17).Value = 1
If chk13.Value = False Then .Cells(lRow, 17).Value = 0
End With
Set Ws = Worksheets("Team totaal")
With Ws
.Cells(lRow, 3).Value = Naam
.Cells(lRow, 4).Value = Format(Date, "DD-MM-YYYY") & " " & Format(Time, "HH:MM")
If chk1.Value Then .Cells(lRow, 6).Value = 1
If chk1.Value = False Then .Cells(lRow, 6).Value = 0
If chk2.Value Then .Cells(lRow, 7).Value = 1
If chk2.Value = False Then .Cells(lRow, 7).Value = 0
If chk3.Value Then .Cells(lRow, 8).Value = 1
If chk3.Value = False Then .Cells(lRow, 8).Value = 0
If chk4.Value Then .Cells(lRow, 9).Value = 1
If chk4.Value = False Then .Cells(lRow, 9).Value = 0
If chk5.Value Then .Cells(lRow, 10).Value = 1
If chk5.Value = False Then .Cells(lRow, 10).Value = 0
If chk6.Value Then .Cells(lRow, 11).Value = 1
If chk6.Value = False Then .Cells(lRow, 11).Value = 0
If chk7.Value Then .Cells(lRow, 12).Value = 1
If chk7.Value = False Then .Cells(lRow, 12).Value = 0
If chk8.Value Then .Cells(lRow, 13).Value = 1
If chk8.Value = False Then .Cells(lRow, 13).Value = 0
If chk9.Value Then .Cells(lRow, 14).Value = 1
If chk9.Value = False Then .Cells(lRow, 14).Value = 0
If chk10.Value Then .Cells(lRow, 15).Value = 1
If chk10.Value = False Then .Cells(lRow, 15).Value = 0
If chk11.Value Then .Cells(lRow, 16).Value = 1
If chk11.Value = False Then .Cells(lRow, 16).Value = 0
If chk12.Value Then .Cells(lRow, 17).Value = 1
If chk12.Value = False Then .Cells(lRow, 17).Value = 0
If chk13.Value Then .Cells(lRow, 18).Value = 1
If chk13.Value = False Then .Cells(lRow, 18).Value = 0
End With
Maybe this is not the correct way to set up a summary sheet and someone has a more efficient way to do this. Any help is welcome
The best way to approach solving a problem with code is to break it down to very simple functions and sub routines.
Here is my thought processes.
We are probably going to be referring to the "Team totaal" worksheet in many of of the macros. Ws is meaningless. I would change the code name of the worksheet to wsTeamTotaal. but this also works:
Function wsTeamTotaal() As Worksheet
Set wsTeamTotaal = ThisWorkbook.Worksheets("Team totaal")
End Function
Next I know that I need to target the next available row in wsTeamTotaal. This should do it.
Function TeamTotalNewRow() As Range
With wsTeamTotaal
Set TeamTotalNewRow = .Cells(.Rows.Count, 3).End(xlUp).Offset(1, 0)
End With
End Function
Do I write a 60 line script to test it? Hell no!! This function selects the first cell in the new row.
Sub GotoTeamTotalNewRow()
Application.Goto TeamTotalNewRow
End Sub
Okay now I write a script to gather all the information and append the row, right? Wrong! Writing a function that accepts variable number of arguments using a ParamArray simplifies the process. Now I can append 1 value of 60+ values without any major modifications.
Sub AppendTeamTotaalRow(ParamArray Args() As Variant)
With TeamTotalNewRow
.Resize(1, UBound(Args) + 1).Value = Args
End With
End Sub
So time to spend a hour writing a userform, gather the data and then testing the append method. Of course not. What's easier to test, a userform packed full of functionality and controls or one simple sub routine?
Sub TestAddNewTeamTotalRow()
Dim TimeStamp As String
TimeStamp = Format(Date, "DD-MM-YYYY") & " " & Format(Time, "HH:MM")
AppendTeamTotaalRow TimeStamp, True, False, True, False
End Sub
Notice that I broke this problem do to it's simplest terms and solved each problem separately. We now have 2 functions, a sub routine and two tests. Each routine performs a single task and no routine has more than 5 lines. Simplify, simplify, simplify, it's that simple.
Complete Code
Function TeamTotalNewRow() As Range
With wsTeamTotaal
Set TeamTotalNewRow = .Cells(.Rows.Count, 3).End(xlUp).Offset(1, 0)
End With
End Function
Function wsTeamTotaal() As Worksheet
Set wsTeamTotaal = ThisWorkbook.Worksheets("Team totaal")
End Function
Sub GotoTeamTotalNewRow()
Application.Goto TeamTotalNewRow
End Sub
Sub AppendTeamTotaalRow(ParamArray Args() As Variant)
With TeamTotalNewRow
TeamTotalNewRow.Resize(1, UBound(Args) + 1).Value = Args
End With
End Sub
Sub TestAddNewTeamTotalRow()
Dim TimeStamp As String
TimeStamp = Format(Date, "DD-MM-YYYY") & " " & Format(Time, "HH:MM")
AppendTeamTotaalRow TimeStamp, True, False, True, False
End Sub

Excel VBA Error 424 with lstDisplay.ColumnCount

I am getting a runtime error 424 in my VBA code while trying to display records. It does not seem to be acknowledging lst.Display.ColumnCount and lst.Display.RowSource. Would very much appreciate the help to mitigate the issue. Every time I run the code, it shows me the 424 runtime error message pointing to the lstDisplay.ColumnCount and lstDisplay.RowSource lines.
Private Sub CommandButton1_Click()
Dim wks As Worksheet
Dim AddNew As Range
Set wks = Sheet1
Set AddNew = wks.Range("A65356").End(xlUp).Offset(1, 0)
AddNew.Offset(0, 0).Value = TextBox1.Text
AddNew.Offset(0, 1).Value = TextBox2.Text
AddNew.Offset(0, 2).Value = TextBox3.Text
AddNew.Offset(0, 3).Value = TextBox4.Text
AddNew.Offset(0, 4).Value = TextBox5.Text
AddNew.Offset(0, 5).Value = TextBox6.Text
AddNew.Offset(0, 6).Value = TextBox7.Text
AddNew.Offset(0, 7).Value = TextBox8.Text
AddNew.Offset(0, 8).Value = TextBox9.Text
AddNew.Offset(0, 9).Value = TextBox10.Text
lstDisplay.ColumnCount = 10
lstDisplay.RowSource = "B1: J65356"**
End Sub
Private Sub CommandButton2_Click()
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub CommandButton3_Click()
Dim i As Integer
For i = 0 To Range("A65356").End(xlUp).Row - 1
If lstDisplay.Selected(i) Then
Rows(i + 1).Select
Selection.Delete
End If
Next i
End Sub
I expect a list to be displayed in my form but it keeps on showing the error.

How to input data and formulas on the same line of excel

I have made a simple form to allow me to input data and store it on an excel table. Before adding simple formulas I was able to submit and the data and populate the next line of the excel table when I hit submit on my form.
I have now added simple formulas that will be used on the data I submit, however when I try to submit data, the formula and inputted data split over 2 separate line in my Excel table (as you can see in the attached image). Can you help me populate the data into the same line as the formulas.
Apologies for any bad code as I haven't tidied it yet, just getting the basics right.
Private Sub CommandButton1_Click()
lastrow = ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count, 2).End(xlUp).Row
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 1).Value = TextBox1.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 3).Value = TextBox9.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 8).Value = TextBox12.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 10).Value = TextBox11.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 11).Value = TextBox10.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 16).Value = TextBox15.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 18).Value = TextBox14.Text
ThisWorkbook.Worksheets("Sheet1").Cells(lastrow + 1, 19).Value = TextBox13.Text
Sheets("Sheet1").Range("A4").Select
ActiveCell.EntireRow.Insert shift:=xlDown
Sheets("Sheet1").Range("A4:V4").Select
Selection.Borders.Weight = xlThin
Sheets("Sheet1").Range("b4").Select
ActiveCell.Formula = "=(a4*1440)"
Sheets("Sheet1").Range("d4").Select
ActiveCell.Formula = "=(b4*(c4/100))"
Sheets("Sheet1").Range("e4").Select
ActiveCell.Formula = "=((d4/b4)*100)"
Sheets("Sheet1").Range("f4").Select
ActiveCell.Formula = "=(100-e4)"
Sheets("Sheet1").Range("i4").Select
ActiveCell.Formula = "=(h4*1440)"
Sheets("Sheet1").Range("l4").Select
ActiveCell.Formula = "=(i4*(((j4+k4)/2)/100))"
Sheets("Sheet1").Range("m4").Select
ActiveCell.Formula = "=((l4/i4)*100)"
Sheets("Sheet1").Range("n4").Select
ActiveCell.Formula = "=(100-m4)"
Sheets("Sheet1").Range("q4").Select
ActiveCell.Formula = "=(p4*1440)"
Sheets("Sheet1").Range("t4").Select
ActiveCell.Formula = "=(q4*(((r4+s4)/2)/100))"
Sheets("Sheet1").Range("u4").Select
ActiveCell.Formula = "=((t4/q4)*100)"
Sheets("Sheet1").Range("v4").Select
ActiveCell.Formula = "=(100-u4)"
End Sub
Don't use .Select. You might benefit from reading
How to avoid using Select in Excel VBA.
Use a variable InsertRow instead of LastRow and add + 1 there. So the calculation is done only once and not in every line you use it.
Use the InsertRow for your values and formulas, and adjust the formulas from row dependent formulas A4 to row independent A:A so the work in every row and not only row 4.
You should name your Button and TextBoxes properly (meaningful). Numbering them is the worst solution as you can easily mix them up and end up in a mess of controls.
So you end up with:
Option Explicit
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
Dim InsertRow As Long
InsertRow = ws.Cells(ws.Rows.Count, 2).End(xlUp).Row + 1
With ws
.Cells(InsertRow, 1).Value = TextBox1.Text
.Cells(InsertRow, 3).Value = TextBox9.Text
.Cells(InsertRow, 8).Value = TextBox12.Text
.Cells(InsertRow, 10).Value = TextBox11.Text
.Cells(InsertRow, 11).Value = TextBox10.Text
.Cells(InsertRow, 16).Value = TextBox15.Text
.Cells(InsertRow, 18).Value = TextBox14.Text
.Cells(InsertRow, 19).Value = TextBox13.Text
.Cells(InsertRow, "B").Formula = "=(A:A*1440)"
.Cells(InsertRow, "D").Formula = "=(B:B*(C:C/100))"
.Cells(InsertRow, "E").Formula = "=((D:D/B:B)*100)"
.Cells(InsertRow, "F").Formula = "=(100-E:E)"
.Cells(InsertRow, "I").Formula = "=(H:H*1440)"
.Cells(InsertRow, "L").Formula = "=(I:I*(((J:J+K:K)/2)/100))"
.Cells(InsertRow, "M").Formula = "=((L:L/I:I)*100)"
.Cells(InsertRow, "N").Formula = "=(100-M:M)"
.Cells(InsertRow, "Q").Formula = "=(P:P*1440)"
.Cells(InsertRow, "T").Formula = "=(Q:Q*(((R:R+S:S)/2)/100))"
.Cells(InsertRow, "U").Formula = "=((T:T/Q:Q)*100)"
.Cells(InsertRow, "V").Formula = "=(100-U:U)"
End With
' not sure if this is needed
' ws.Cells(InsertRow, "A").EntireRow.Insert shift:=xlDown
ws.Range("A" & InsertRow & ":V" & InsertRow).Borders.Weight = xlThin
End Sub
Sheets("Sheet1").Range("A4").Select
ActiveCell.EntireRow.Insert shift:=xlDown
The code above might move down your data. Why not you create the formula directly at the excel sheet?

Pull five unique numbers from a range and display in Text boxes using Excel VBA

I have a table of numbers like below in a excel sheet.
Excel Table
No1 No2 No3 No4 No5
1 190 134 190 101
10 142 117 10 151
155 12 12 12 128
154 154 154 154 154
I have a UserForm with 5 TextBoxes to display 5 unique numbers from the table.
When I click on the command button, It should pull 5 UNIQUE numbers from the above table and display it in the TextBoxes respectively.
Also, If I click on the command button again(i.e. Multiple Clicks to get more result), It should populate a different UNIQUE numbers from the table.
I used simple if else concept to achieve this but it is not working correctly.
Please assist me to achieve the result. Thank you!
I use the below code:
Private Sub btnGenerate_Click()
Dim PresentRow As Byte, PresentColumn As Byte
PresentRow = ActiveCell.Row
PresentColumn = ActiveCell.Column
If PresentRow = 5 And PresentColumn = 1 Then
Sheet1.Range("F2").Activate
ElseIf PresentRow = 5 And PresentColumn = 5 Then
Sheet1.Range("A2").Activate
End If
Select Case ActiveCell.Column
Case 1
TextBox1.Text = ActiveCell.Value
If ActiveCell.Offset(0, 1).Value <> TextBox1.Text Then
TextBox2.Text = ActiveCell.Offset(0, 1).Value
Else
TextBox2.Text = ActiveCell.Offset(1, 1).Value
End If
If ActiveCell.Offset(0, 2).Value <> TextBox2.Text Then
TextBox3.Text = ActiveCell.Offset(0, 2).Value
Else
TextBox3.Text = ActiveCell.Offset(1, 2).Value
End If
If ActiveCell.Offset(0, 3).Value <> TextBox3.Text Then
TextBox4.Text = ActiveCell.Offset(0, 3).Value
Else
TextBox4.Text = ActiveCell.Offset(1, 4).Value
End If
If ActiveCell.Offset(0, 4).Value <> TextBox4.Text Then
TextBox5.Text = ActiveCell.Offset(0, 4).Value
Else
TextBox5.Text = ActiveCell.Offset(1, 5).Value
End If
Case 5
TextBox1.Text = ActiveCell.Value
If ActiveCell.Offset(0, -1).Value <> TextBox1.Text Then
TextBox2.Text = ActiveCell.Offset(0, -1).Value
Else
TextBox2.Text = ActiveCell.Offset(1, -1).Value
End If
If ActiveCell.Offset(0, -2).Value <> TextBox2.Text Then
TextBox3.Text = ActiveCell.Offset(0, -2).Value
Else
TextBox3.Text = ActiveCell.Offset(1, -2).Value
End If
If ActiveCell.Offset(0, -3).Value <> TextBox3.Text Then
TextBox4.Text = ActiveCell.Offset(0, -3).Value
Else
TextBox4.Text = ActiveCell.Offset(1, -4).Value
End If
If ActiveCell.Offset(0, -4).Value <> TextBox4.Text Then
TextBox5.Text = ActiveCell.Offset(0, -4).Value
Else
TextBox5.Text = ActiveCell.Offset(1, -5).Value
End If
End Select
Sheet1.Activate
ActiveCell.Offset(1, 0).Select
End Sub
The following requires that Microsoft Scripting Runtime be added to the project via Tools, References.
In the worksheet code sheet:
Option Explicit
Private Sub CommandButton1_Click()
Dim txt As Long, vals As Variant, ky As Variant
Dim uniq As New Scripting.Dictionary
vals = Range("A2:E5").Value2
uniq.RemoveAll
Do While uniq.Count < 5
uniq.Item(vals(Application.RandBetween(LBound(vals, 1), UBound(vals, 1)), _
Application.RandBetween(LBound(vals, 2), UBound(vals, 2)))) = vbNullString
Loop
TextBox1 = uniq.Keys(0)
TextBox2 = uniq.Keys(1)
TextBox3 = uniq.Keys(2)
TextBox4 = uniq.Keys(3)
TextBox5 = uniq.Keys(4)
End Sub

How To: Excel VBA Command Button Enters UserForm Values to Current Row?

I currently have a UserForm "UserForm1" that takes values (Lesson, Instructor, Start Time, etc.) from ComboBoxes and saves them to a designated sheet "InstructorHours". The CommandButton "Save" saves the selected values in the next available line on the "InstructorHours" sheet. What I'm having trouble with is having the CommandButton save the same information into a currently selected row on another Worksheet "Calendar". Ideally I would like to click within a row on my "Calendar" sheet and input the values from the User from into the row I've selected.
Private Sub CommandButton1_Click()
'Copy input values to sheet.
Dim lRow As Long
'next available row
Dim ws As Worksheet
Set ws = Worksheets("InstructorHours")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.ComboBox1.Value
.Cells(lRow, 2).Value = Me.ComboBox2.Value
.Cells(lRow, 3).Value = Me.ComboBox3.Value
.Cells(lRow, 4).Value = Me.ComboBox4.Value
.Cells(lRow, 5).Value = Me.ComboBox5.Value
.Cells(lRow, 6).Value = Me.ComboBox6.Value
.Cells(lRow, 7).Value = Me.TextBox1.Value
End With
'Clear input controls.
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.ComboBox3.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.ComboBox6.Value = ""
End Sub
Any and all help is much appreciated. Thank you.
In general, if you want to work on something active, you would want something "Active" (e.g. ActiveSheet or ActiveCell) for your active-selection activities.
I would recommend another Command Button for the following (Writing this up off the top of my head, haven't verified the code):
Private Sub CommandButton2_Click()
'Input based on the selection
ActiveCell.Value = Me.ComboBox1.Value
ActiveCell.Offset(1,0).Value = Me.ComboBox2.Value
ActiveCell.Offset(2,0).Value = Me.ComboBox3.Value
ActiveCell.Offset(3,0).Value = Me.ComboBox4.Value
ActiveCell.Offset(4,0).Value = Me.ComboBox5.Value
ActiveCell.Offset(5,0).Value = Me.ComboBox6.Value
ActiveCell.Offset(6,0).Value = Me.TextBox1.Value
'Clear input controls.
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.ComboBox3.Value = ""
Me.ComboBox4.Value = ""
Me.ComboBox5.Value = ""
Me.ComboBox6.Value = ""
End Sub
That should provide, at least, a starting point.

Resources