ListObjects and Table's cell column - Insert records by column name [VBA]

iliomil

New Member
Joined
Nov 27, 2018
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Good evening everyone.
I need your help building an "Insert" click event routine via command button.
  • I have a Structured table called "myTable" with a variable number of columns (they represent the names of the districts);
  • The Header Range has the name "DistrictHeaderRange";
  • I have a form with 4 controls: 1 combobox, 1 textbox, 1 listbox, 1 command button.
In my other tables, I used routine like this to insert new records into worksheets:
VBA Code:
 ActiveSheet.ListObjects("myTable").ListRows.Add
Routine works fine, apart not insert value in first empty cells but writing directly to the first available row after the last record.
Is it possible to build a routine that writes a value (Washington) from TextBox1 in the first empty cell of the column (District of Columbia ) chosen through ComboBox1?
I would like to choose the district from ComboBox1 and insert a new city (therefore dependent on the district) and store it in the Excel sheet in vertical.
I made several attempts but I gave up.
Thank you for your help
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Table's structure. Just two columns for now
mr_excel_range.png
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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