Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2006, 05:23 AM
Authorized User
 
Join Date: Apr 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy visible cells

Hi all,

I would like to copt the visible cells on a worksheet but NOT record number 1 how can this be achieved.
I have this:

ThisWorkbook.Sheets(4).UsedRange.SpecialCells(xlCe llTypeVisible).Select

But how can I change this to exclude record number 1

Regards,

Paul.

 
Old December 22nd, 2006, 11:54 AM
Registered User
 
Join Date: Dec 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't claim to be a wiz at VBA, but give this a try. I stepped through it and it seemed to work without doing anything to the selected visible cells.
Code:
Sub cpyfour()
    ThisWorkbook.Sheets(4).Rows("1:1").Select
    Selection.EntireRow.Hidden = True
    ThisWorkbook.Sheets(4).UsedRange.SpecialCells(xlCellTypeVisible).Select

    ' copy paste code here

    Rows("1:1").Select
    Selection.EntireRow.Hidden = False
End Sub
You might have to specify the original sheet(4) when setting the hidden property to false. As they say, your mileage may vary.

 
Old January 3rd, 2007, 11:43 PM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sub SelectVisibleCellExceptFieldNameAndFirstRecord()
Dim tbl As Range
Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 2, _
    tbl.Columns.Count).SpecialCells(xlCellTypeVisible) .Copy
    Sheets.Add After:=S heets(Sheets.Count)
    ActiveSheet.Paste
End Sub

N. Yauvasuta





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy visible cells in a macro?Runtime 438 error? nbaj2k Excel VBA 2 April 7th, 2010 11:13 AM
Disabling copy function for selected cells yatinjhamb Excel VBA 3 March 21st, 2008 04:01 AM
Copy specific data in specific cells of sheet2 yogeshyl Excel VBA 1 May 14th, 2007 07:40 AM
visible vs. not visible on form akibaMaila VB.NET 2002/2003 Basics 2 August 15th, 2005 02:40 PM
Copy cells from an excel file opened in a browser escorido Excel VBA 0 July 6th, 2004 01:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.