How to copy non-contiguous range, without hidden columns for a PPT picture paste

blueroo123

New Member
Joined
Apr 25, 2015
Messages
6
Everyone:

I have something that has been bugging me: I am trying to use VBA to copy a range that has hidden columns in the middle (and do not want those columns copied). I know in regular Excel (Excel 2013 in my case), one simply right-clicks on the selection and the selection is copied without the hidden rows or columns. In this particular case, I am trying to do the same, but through VBA...see below my code, which does not seem to work:

Code:
  Columns("F:J").Select
    Selection.EntireColumn.Hidden = True
   
    
    Range("C7:P50").SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    
    Columns("F:J").Select
    Selection.EntireColumn.Hidden = False
    
    MsgBox "Data is now copied and ready for the PPT"
    Application.ScreenUpdating = True
    Range("c9").Select

Any thoughts?

Cheers
Jonathan
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi Jonathan

See if this example is useful:

Code:
Sub BlueRoo()
Dim r As Range, i%, c As Range
Columns("F:J").EntireColumn.Hidden = True
Set c = Range("C7:P50").SpecialCells(xlCellTypeVisible)
Set r = c.Areas(1)
For i = 2 To c.Areas.Count      ' a range can have one or more areas
    Set r = Union(r, c.Areas(i))
Next
r.Copy Sheets("Data").Range("a1")
Columns("F:J").EntireColumn.Hidden = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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