Copy 4 columns from smart table to other smart table

Adamsxl

New Member
Joined
Apr 18, 2024
Messages
1
Office Version
  1. 2021
Platform
  1. Windows
Hello everyone,

I hope you can help me!?
I'm trying to use VBA to copy the first 4 columns from an intelligent/smart table that has 10 or more columns into another intelligent/smart table.
The additional problem is that only the displayed rows from the table should be copied (if filters are set). I have already found out that I have to use “xlCellTypeVisible” for this.

Currently my code looks like this:
VBA Code:
Option Explicit
Sub CopyData()
Worksheets(1).ListObjects("TableCom").ListColumns(2).DataBodyRange.SpecialCells(xlCellTypeVisible).Copy Destination:=Worksheets(2).ListObjects("TableColl").ListColumns(1)
End Sub

I get an Error = runtime error 9

Can you please help me with a working code? I don´t know much about vba.

Thank you and see you soon
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hello

Have you try this way? (Change the column number as you like)

VBA Code:
Sub CopyData()
ThisWorkbook.Sheets(1).Range("TableCom").Columns(2).SpecialCells(xlCellTypeVisible).Copy Destination:=ThisWorkbook.Sheets(2).Range("TableColl").Columns(1)
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,332
Messages
6,124,314
Members
449,153
Latest member
JazzSingerNL

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