Transferring information from a User Form to a table

cmerrick

Board Regular
Joined
Jun 8, 2017
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Good morning/afternoon,

I have a some code that I'm using to transfer data from a user form to a table. The code was set up to place the data in the last row of the table (creating more rows). I've used it before so I know that this code works. The problem I have with the new table, is that the last 4 rows are used to total various columns so I need the new rows to be added above the last 4 rows.

The functionality should remain the same, so I want each new row to shift the last 4 rows down by one if that that makes sense?

If anyone can assist it would be great.

This is the code I'm using at the moment.

Code:
Private Sub CommandButton2_Click()
Dim emptyRow As Long
 
 Sheet3.Activate
 
 
 emptyRow = Sheets(3).Range("AS" & Rows.Count).End(xlUp).Row + 1
 
 Cells(emptyRow, 4).Value = TextBox1.Value
 
 Cells(emptyRow, 8).Value = ComboBox5.Value
 Cells(emptyRow, 9).Value = ComboBox6.Value
 
 
 Cells(emptyRow, 12).Value = ComboBox7.Value
 Cells(emptyRow, 13).Value = ComboBox8.Value
 
 Cells(emptyRow, 16).Value = ComboBox9.Value
 Cells(emptyRow, 17).Value = ComboBox10.Value
 
 Cells(emptyRow, 20).Value = ComboBox11.Value
 Cells(emptyRow, 21).Value = ComboBox12.Value
 
 Cells(emptyRow, 24).Value = ComboBox13.Value
 Cells(emptyRow, 25).Value = ComboBox14.Value
 
 Cells(emptyRow, 39).Value = ComboBox1.Value
 
 Cells(emptyRow, 42).Value = ComboBox2.Value
 Cells(emptyRow, 43).Value = ComboBox3.Value
 Cells(emptyRow, 44).Value = ComboBox4.Value
 
 
If OptionButton5.Value = True Then
     Cells(emptyRow, 5).Value = "FT"
Else
     Cells(emptyRow, 5).Value = "PT"
     
End If
     
If OptionButton1.Value = True Then
     Cells(emptyRow, 6).Value = "Y"
Else
     Cells(emptyRow, 6).Value = "N"
     
End If
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try
Code:
emptyrow = Sheets(3).Range("AS" & Rows.Count).End(xlUp).Row - 3
Rows(emptyrow).Insert
 
Upvote 0
Hiya,

Thanks for the help.

It's working but it keeps bringing up the file open window too for some reason ?

Any ideas ?
 
Upvote 0
Do you have any formulas that reference other workbooks?
 
Upvote 0
Ahh, yes I do.

There are two columns hat reference an external document.

The one user form adds new employees to the spreadsheet (the one we are coding)

The other calls and allows to edit the data then sends it back (for existing employees)


This causes an issue because there are items of data that a new employee will not have (the data that is being referenced from another workbook).

Is there a way around this ?

Thank you kindly
 
Upvote 0
Is there a way around this ?
Almost certainly yes, but I'm not to familiar with this sort of thing.
However if you can supply a mock-up of both sheets, & show what your formulae are, then hopefully somebody else can step in and help.
 
Upvote 0
In theory it should be fairly simple. We are just doing the same but ignoring the formula in the first two columns that pulls down when a new row is created.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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