-1

I have an Excel table, and a form control (button) which select specific data from the table and copy it into mail. I would like to know how can I select only some columns from the table, not all of the columns?

Please your assistance, Thanks

Here is part of my code:

Sub SendCA_list()

Call FilterCA 'filter the table per specific data

Range("Table4[[#Headers],[Department]]").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select 'select all the columns after the column 'department'- how to select only 10 columns?
ActiveWindow.SmallScroll Down:=-129
Selection.Copy
braX
  • 11,506
  • 5
  • 20
  • 33
Shira L.
  • 81
  • 12
  • You could try : Range(Table Name & "[[Column Start]:[Column End]]").Select – Error 1004 Oct 22 '18 at 11:37
  • @Error1004 Thanks, i tried this line: `Range("Table4[[Department]:[Status]]").Select` and it is working and provide selecting the required data in the table, but i need also the Headers, do you know how to select them to? – Shira L. Oct 22 '18 at 19:28

2 Answers2

2

You don't need to select anything.

Range("Table4[[#All],[Column1]],Table4[[#All],[Column2]],Table4[[#All],[Column4]]").Copy
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • Thanks @GSerg. I have many column to copy, so writing each of them is not the most inefficient way.. `Range("Table4[[Department]:[Status]]").Select` - this code work fine but without the headers, do you know how can i select them to?. – Shira L. Oct 22 '18 at 19:33
  • @ShiraL. `Range("Table4[[#All],[Department]:[Status]]").Select` – GSerg Oct 22 '18 at 20:05
0

@ShiraL try ti import [#All] before the columns name:

Range("Table4[[#All],[Department]:[Status]]").Select
Error 1004
  • 7,877
  • 3
  • 23
  • 46