VBA and Table Help Please

cmerrick

Board Regular
Joined
Jun 8, 2017
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hi,

I had some help earlier to transfer information from a user form into a table using the following code

Code:
Private Sub CommandButton2_Click()
Dim emptyRow As Long
 
 Sheet3.Activate
 
 
 emptyrow = Sheets(3).Range("AS" & Rows.Count).End(xlUp).Row - 3
Rows(emptyrow).Insert
 
 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

What this does is transfer the data into the table and places it into a new row, four rows from the bottom. Great.

The first two columns of the table though have formulas to reference data from another work book. Is there a way to add the new rows in and then remove any data from the first two columns? The reason I want this removing is because it brings up the file open window twice due to there being two columns.

Regards
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Before End Sub, try adding:
Code:
Cells(emptyRow,1).Resize(,2).ClearContents
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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