Pushing new Userform Data into new Row in a specific Range

DinnerB0ne

New Member
Joined
Feb 17, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
New poster here, apologies if any annoyance caused.

I am trying to have my User form input it's data into a new row in a set range - but when I seem to do it it just will overwrite a pre-existing row WITH data inside of it.

Within one sheet I have two Catergories (not tables); One Called Insurance Claims and one Called Warranty Claims. What I want to do is create a button that will bring up a form that you fill out and will
automatically input the data into the correct table.

I have managed to get 50% of the way there and I have created the form and the data does indeed paste in the sheet. But it will overwrite a row with data already inside of it, where I want it to go to the bottom of the Insurance
Claim Rows -> insert the data -> add new row for next set of data. The Insurance Claim rows start from A3:A35 at the moment. I have attached photos to try and better understand this.

I'll input my code here for the form also

VBA Code:
Private Sub CancelButton_Click()

Unload Me

End Sub

Private Sub OKButton_Click()

Dim emptyRow As Long

'Make Insurance & Warranty Claims sheet active
Sheet1.Activate

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

'Transfer information
Cells(emptyRow, 1).Value = TodaysDateBox.Value
Cells(emptyRow, 2).Value = NameBox.Value
Cells(emptyRow, 4).Value = AssetTagBox.Value
Cells(emptyRow, 6).Value = SerialNumberBox.Value
Cells(emptyRow, 7).Value = DamageBox.Value
Cells(emptyRow, 9).Value = NoteBox.Value
Cells(emptyRow, 10).Value = LocationListBox.Value
Cells(emptyRow, 11).Value = StatusBox.Value
Cells(emptyRow, 12).Value = HandlerBox.Value

Unload InsForm1

End Sub

Private Sub UserForm_Initialize()

'Empty TodaysDateBox
TodaysDateBox.Value = ""

'Empty NameBox
NameBox.Value = ""

'Empty AssetTagBox
AssetTagBox.Value = ""

'Empty SerialNumberBox
SerialNumberBox.Value = ""

'Empty DamageBox
DamageBox.Value = ""

'Empty NoteBox
NoteBox.Value = ""

'Empty LocationListBox
LocationListBox.Clear

'Fill LocationListBox
With LocationListBox
    .AddItem "Kings"
    .AddItem "Castle"
End With

End Sub

Please help me beat this !! Many thanks!
 

Attachments

  • 1.png
    1.png
    74.3 KB · Views: 14
  • 2.png
    2.png
    78.9 KB · Views: 14
  • 3.png
    3.png
    111.8 KB · Views: 12

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
TL;DR

Want Userform to add new row on Last Row of Insurance Claims
Current code overwrites pre-existing rows with Data inside
Currently driving me insane :ROFLMAO:

Ultimate noob to VBA also
 
Upvote 0
Update #1

Just did some testing in a scrap doc so the code works perfectly without fault when I seperate 'Warranty Claims' to another Sheet. I want to avoid this if possible as There already 6+ sheets so would like to keep these two in the same sheet IF POSSIBLE!
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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