Add new rows to table based on another table value

madvogue29

New Member
Joined
Aug 28, 2020
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi All again! I am stuck again in a pickle and I have no idea how to get out of it. I am a newbie and this forum has been a life savior.


I want the orange table to add a new column and fill it with check boxes each time a new member is added in Blue table.
and If a new row is added in the orange table it added the check boxes too.

I am not sure if this is possible or not. I tried but didnt succeed so i thought this place would be the best place to ask.
1600075540250.png


Thanks in advance again.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Update: I may look for alternative for checkboxes as I am not sure if that is the correct way for me. But I would still appreciate the a solution for adding new Column in Orange table when new data is added in the blue table.

Thanks again
 
Upvote 0
try something along the lines of this to add the table column
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.CountLarge > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub

If Not Intersect(Target, ActiveSheet.ListObjects("Table1").DataBodyRange) Is Nothing Then
    With ActiveSheet.ListObjects("Table2")
        .ListColumns.Add
        .HeaderRowRange(, .ListColumns.Count).Value = Target.Value
        '.HeaderRowRange.Cells(, .ListColumns.Count).EntireColumn.AutoFit
    End With
End If

End Sub
 
Upvote 0
This works like a charm! You are the man!!

Also to fix the checkbox issue I added this script

VBA Code:
Sub ChangeValue()
Dim text As String
text = ActiveCell.value

If text = "P" Then
ActiveCell.value = "O"

ElseIf text = "O" Then
ActiveCell.value = "P"

Else
ActiveCell.value = "P"
End If

End Sub

"P" and "O" in Windings 2 font are ticks and crosses.

then I added this for triggering this module

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Not Intersect(Target, Range("O52")) Is Nothing Then
            Call Module4.ChangeValue
        End If
End Sub

Ignore the Range("O52") this was just a test cell. I will update it to match my table.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

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