Automatically adding rows to one table based on cell value of another table

dallen8028

New Member
Joined
Jan 28, 2013
Messages
48
I am looking to Automatically add rows to one table based on cell value of another table. Example: If [Table 1 [cell A1]]="Maintenance" then [Table 2] will copy [Table 1 [Cells B1,C1]] to [Table 2[cells F1,G1]] then auto TAB to add a new row to [Table 2] for the next "Maintenance" match. As entries are input to Table 1 that have "Maintenance" in cell A1 the process continues. I would upload the two tables but I do not have upload privileges yet. I apologize for any confusion ahead of time. Please advise. Thanks in advance.
 
Use the script in Post 7

It should do what you want.
If not tell me what it did wrong.

You cannot know what it does till you test it.

Try it on a copy of your workbook.

Thanks again. I am not very wise with scripts so i do not know how to write them. I can and will attempt to modify the script with exact locations of the columns (cells). I will let you know. If I had upload capabilities you would be able to take care of this (and probable more) as you would see exactly what I need to do. How might I gain that privilege?

Our school year is beginning and I am very busy during the day. I am currently living in Guatemala as a missionary for a American Christian school. All of our staff and teachers are volunteers.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Thanks again. I am not very wise with scripts so i do not know how to write them. I can and will attempt to modify the script with exact locations of the columns (cells). I will let you know. If I had upload capabilities you would be able to take care of this (and probable more) as you would see exactly what I need to do. How might I gain that privilege?

Our school year is beginning and I am very busy during the day. I am currently living in Guatemala as a missionary for a American Christian school. All of our staff and teachers are volunteers.

I have attempted to change the table addresses and received the following debug response (Italic, Bold Underlined):

Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 8/10/2018 12:59:40 AM EDT
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim ans As Long
If Not Intersect(Target, [Table6185115[Column4]]) Is Nothing Then
If Target.Value = "Maintenance" Then
ans = [Table65014[Column4]].Columns.Rows.Count + 2
Cells(Target.Row, [Table6185115[Column1]].Column).Copy Cells(ans, [Table6185115[Column1]].Column)
Cells(Target.Row, [Table6185115[Column5]].Column).Copy Cells(ans, [Table6185115[Column4]].Column)
End If
End If
End Sub
 
Upvote 0
Why would you name your Table:

Table6185115


Till you learn Excel why not just use a simple name like I did which are default names

I used Table1 and Table2

Do you really have 6 million Tables in your workbook

Or name your table Me and You
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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