LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets)

Hello,

From an existing source workbook, I need to copy two specific sheets
(where both sheets now contain autofiltered rows and hidden columns)
and paste them into a new destination workbook also containing two
worksheets (but these destination worksheets should not contain those
autofiltered rows and hidden columns). Eventually I need to email
that new destination workbook.

To acheive this, I am using Ron De Bruin's macro code for "Mail Range
or Selection" (http://www.rondebruin.nl/mail/folder2/mail4.htm).

Be mindful that I need the new destination workbook to only have those
two sheets with just the visible data with all formatting intact (just
eliminate invisible data and NOT to have those filtered rows and
hidden columns). If this was not the case, I could have simply used
an array statement that Ron De Bruin uses in one of his other email
macro examples.
..Sheets(Array("Sheet1", "Sheet3")).Copy

With that being said, I have already modified Ron's code but it only
works for one sheet. I need this to happen to another sheet as well.
Also I would like to hard code both these sheet names in the macro
with their codenames, if possible. Any alternative methods which
could be effective and efficient, are also welcome.

Any help will be greatly appreciated. Thanks in advance. Here is the
modified code.

Set Source = Nothing
On Error Resume Next
Set Source = ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisib le)
On Error GoTo 0

If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, "
& _
"please correct and try again.", vbOKOnly
Exit Sub
End If

Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
'Assigning source workbook's sheet name to the copied sheet
in this new workbook
.Name = wb.Sheets(1).Name
Application.CutCopyMode = False
End With
 
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 Visible Sheets to New File Troubled User Excel Programming 3 September 9th 07 10:26 PM
Can I copy just the visible sheets? Trefor Excel Discussion (Misc queries) 2 September 3rd 06 02:31 PM
Copy Visible Sheets into one Workbook Clay Excel Programming 3 March 29th 06 04:19 PM
3 sheets in workbook, but visible only one? slaya_cz Excel Discussion (Misc queries) 3 September 30th 05 01:37 PM
Delete all visible sheets in workbook... Jim Thomlinson[_4_] Excel Programming 2 August 23rd 05 08:04 PM


All times are GMT +1. The time now is 06:59 PM.

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"