How to input data into certain cells in excel sheet using VBA form?

acousticlife81

New Member
Joined
Mar 29, 2017
Messages
12
I am trying to create a form that allows the user to input data into certain fields. Here is the code for the Submit or Okay Button. The data needs to go from the form to cells B15:I15 AND then once entered add another entry to the next row C16:I16 and etc. Please if anyone can help it would be much appreciated.

'Here is the code!!!!!!!

Private Sub CommandButton2_Click()
Dim emptyRow As Long


'Make Sheet1 active
Sheet1.Activate


'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1


'Transfer information
Cells(emptyRow, 1).Value = NameTextBox.Value
Cells(emptyRow, 2).Value = TaskTextBox.Value
Cells(emptyRow, 3).Value = AssignedByListBox.Value
Cells(emptyRow, 4).Value = StatusComboBox.Value
Cells(emptyRow, 5).Value = DateTextBox.Value


End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi
welcome to forum

see if this update to your code does what you want:

Code:
Private Sub CommandButton2_Click()
    Dim emptyRow As Long
    
    'Determine emptyRow
    emptyRow = Sheet1.Cells(Sheet1.Rows.Count, "B").End(xlUp).Row + 1
    If emptyRow < 15 Then emptyRow = 15
    
    
    'Transfer information
    Sheet1.Cells(emptyRow, 2).Resize(, 5).Value = Array(NameTextBox.Value, TaskTextBox.Value, _
                                                    AssignedByListBox.Value, StatusComboBox.Value, _
                                                    DateValue(DateTextBox.Value))
                                 
End Sub

Dave
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top