LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copy HIDDEN columns to a new workbook

Sorry, but there was too much code in your original message to go through,
so I thought I would just provide an answer to what you posted in your last
message (the one I am replying to now) that you can use as a guide for
modifying your own code.

The following code will copy Columns A:BN from Sheet3 to Sheet5 and the
columns on Sheet5 will all be visible...

Worksheets("Sheet3").columns("A:BN").Copy Worksheets("Sheet5").Range("A1")
Worksheets("Sheet5").Columns("A:BN").Hidden = False

Note that using the Copy method (as I did in my first statement) copies not
only the cells contents, but any formatting that they have as well. Also
note that using this method, does not require selecting or pasting anything
nor do you have to shut off the "marching ants" (the copy selection border
indicator).

--
Rick (MVP - Excel)


"ch-d" wrote in message
...
Hi Joel,

Thank you for this. However, what I wanted to copy was the entire column
A:BN with columns J:L hidden in the sourcesheet but should be visible in
the
new worksheet. Any help? THANKS!

"joel" wrote:


I kike most of your code. Here are some comments and the change you are
asking for


1) It is beeter yo use Thisworkbook rather than Activeworkboook when
refereing to the workbook with the macro. I also like to give the
worksheet a name as well as the range

From

Set My_Range = Worksheets("Sheet1").Range("A1:BN" &
LastRow(Worksheets("Sheet1")))
My_Range.Parent.Select


ActiveWorkbook.Unprotect ("sda")

ActiveSheet.Unprotect ("sda")

to
Set SourceSht = Worksheets("Sheet1")

Set My_Range = SourceSht.Range("A1:BN" & LastRow(Sourcesht))
SourceSht.Select


ThisworkbookWorkbook.Unprotect ("sda")

Sourcesht.Unprotect ("sda")


2) When you do a copy the source type and the destination type must be
the same type object and you only have to specify the first item in the
destination and not the entire area. Just like copying manually on the
workbook.

What I mean is the following
Sheets("Sheet1").cells.copy destination:=Sheets("Sheet2").cells

with Sheets("sheet1")
.rows(1:5).copy destination:=.rows(100)
.columns("A:C").copy destination:=.columns("Z")
.Range("A1:D100").copy destination:=.range("T1")
end with


3) When using Autofilter use specialcells (visible) to copy your data.
You need to unhide the columns before copying

With Sourcesht
.Columns("J:L").hidden = False
Set Copyrange = .Columns("J:L").SpecialCells(xlCellTypeVisible)
Copyrange.Copy Destination:=.Columns("I:J"")
.Columns("J:L").hidden = True
CopyRange.Copy destination:=WSNew.columns("A")
End With


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=170803

Microsoft Office Help

.


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste with hidden columns remaining hidden Pendelfin Excel Discussion (Misc queries) 2 February 26th 09 11:35 AM
Not include hidden columns in copy paste jbc Excel Discussion (Misc queries) 2 July 19th 07 01:46 AM
How do I copy a worksheet so that hidden columns remain secret? Vanessa Long Excel Discussion (Misc queries) 1 July 9th 07 01:42 PM
macro to insert row, copy cells and keep hidden columns steven_thomas Excel Programming 0 September 26th 05 09:40 PM
COPY - *want* to include hidden columns Eric[_27_] Excel Programming 5 July 26th 05 01:58 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"