Copy a table column data to another table column as event

3.6k views Asked by At

I have the following code, which works fine as a module, but i would rather have it working as a worksheet_change (Table_owssvr is connected to an external source):

If Application.WorksheetFunction.CountA(Range("Table_SiteManager[Title]")) <> 0 _
Then Range("Table_SiteManager[Title]").Rows(2).Delete

Range("Table_owssvr[Title]").Copy _
Destination:=Range("Table_SiteManager[Title]")

Any ideas?

Thanks.

1

There are 1 answers

0
Sebastian Koefoed On

I figured out a way myself in case anyone should be interested:

Lastrow = ListObjects("Table_owssvr").Range.Rows.Count

If Target.Column = 1 Then

    Sheets("SiteManagers").Range("Table_SiteManager[Title]").Rows(2).Delete

    Sheets("Permission").Range("Table_owssvr[Title]").Copy _
    Destination:=Sheets("SiteManagers").Range("Table_SiteManager[Title]")

    Sheets("Permission").Range("lastrow").Select

End If