Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default export visible rows only

Use this loop for the delete:

Sub cooz()
Worksheets("Output").Activate
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For n = nLastRow To 1 Step -1
If Cells(n, "A").EntireRow.Hidden = True Then
Rows(n).Delete
End If
Next
End Sub
--
Gary''s Student - gsnu200788


"Cooz" wrote:

Hi everyone,

I use this code to copy a worksheet from one workbook to another:

With wbkExport
wbkCurrent.Worksheets("Output").Copy After:=.Worksheets(1)
End With

The problem is that this worksheet contains hidden rows that should not be
copied. Post-editing with

For Each aRow In wbkExport.Worksheets("Output").UsedRange.Rows
If aRow.Hidden Then
aRow.Delete
End If
Next

does not seem to work - and if it did, it would slow down the macro
considerably (but that is better than getting the hidden rows in the export).
So: I am looking for a fast way to export only visible rows to a new
worksheet. What should I do?

Thank you,
Cooz

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default export visible rows only

Thank you Gary"s Student.
This works nicely. However I found Stefi's proposal somewhat more elegant.
I appreciate your contribution.

Kind regards,
Cooz

"Gary''s Student" wrote:

Use this loop for the delete:

Sub cooz()
Worksheets("Output").Activate
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
For n = nLastRow To 1 Step -1
If Cells(n, "A").EntireRow.Hidden = True Then
Rows(n).Delete
End If
Next
End Sub
--
Gary''s Student - gsnu200788


"Cooz" wrote:

Hi everyone,

I use this code to copy a worksheet from one workbook to another:

With wbkExport
wbkCurrent.Worksheets("Output").Copy After:=.Worksheets(1)
End With

The problem is that this worksheet contains hidden rows that should not be
copied. Post-editing with

For Each aRow In wbkExport.Worksheets("Output").UsedRange.Rows
If aRow.Hidden Then
aRow.Delete
End If
Next

does not seem to work - and if it did, it would slow down the macro
considerably (but that is better than getting the hidden rows in the export).
So: I am looking for a fast way to export only visible rows to a new
worksheet. What should I do?

Thank you,
Cooz

Reply
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
Deleting Visible Rows Confused Excel Discussion (Misc queries) 4 August 7th 08 02:44 PM
Select first 5 visible rows Paul Brown[_2_] Excel Programming 2 January 5th 08 03:19 PM
rows for visible cells mf_digger Excel Programming 2 December 20th 06 11:01 PM
Looping through visible rows only Rasmus[_3_] Excel Programming 1 April 10th 05 02:08 AM
AutoFilter - which rows are currently visible? Bjørnar Hartviksen Excel Programming 2 October 6th 03 12:01 AM


All times are GMT +1. The time now is 09:43 AM.

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

About Us

"It's about Microsoft Excel"