New table row question

Nygie

Board Regular
Joined
Apr 15, 2015
Messages
50
Good afternoon all.

I have a spreadsheet with 5 tabs of various names all with a table in.
They have various details in the tables all with a common key (TempID). I have some code that I found from some nice person on youtube which when I type into cell Bx it populates cell Ax with the next consecutive number from the cell above and the table automatically expands a row as per normal.
The tables are all exactly the same number of rows, all with the same start point in the top left (A1).

My question is... when I add my new record to the first sheet and the new row is added, is it possible to code an addition to the rest of the tables. i.e. AddNewRow to table2, table3, table4 etc.
Or am I just dreaming? I have searched and not found anything about adding rows across tables in a workbook automatically.

Thanks for any comments and suggestions.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This is the code used for adding the ID number.
I was thinking that on this code running, we can assume that a new row has been created a use that as the trigger and add a line of code that does something like "T
able2.ListRows.Add"
. Then repeat the line for table3 etc. I'll have a bash at some code tomorrow & see if I can't cobble something together. It won't be pretty lol and it probably won't work haha



Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then 'This is the column that causesthe ID to be created
'This uses the target offset so it assumes in two spotsbelow that the column to update is "A" and
'that the column is one position to the left of the targetcolumn above
IfTarget.Offset(0, -1).Value = "" Then
Target.Offset(0, -1).Value =Application.WorksheetFunction.Max(Columns("A")) + 1
End If
End If

End Sub

Function Max_Each_Column(Data_Range As Range) As Integer
Dim TempArray() AsDouble, i As Long
If Data_RangeIs Nothing Then Exit Function
WithData_Range
ReDimTempArray(1 To .Columns.Count)
For i = 1 To.Columns.Count
TempArray(i) = Application.Max(.Columns(i))
Next
End With
Max_Each_Column = TempArray
 
Upvote 0
Figured it out, I inserted the below code just before the first End If and it worked :)
Dim ws As Worksheet
Set ws = Sheet2
Dim tbl As ListObject
Set tbl = ws.ListObjects("Table2")
tbl.ListRows.Add
 
Upvote 0

Forum statistics

Threads
1,214,396
Messages
6,119,268
Members
448,881
Latest member
Faxgirl

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