ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   export visible rows only (https://www.excelbanter.com/excel-programming/411505-re-export-visible-rows-only.html)

Stefi

export visible rows only
 
Try this code piece (after unwanted cells are hidden):

Selection.CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy Destination:=Sheets("Output").Range("A1").Select


Regards,
Stefi

€˛Cooz€¯ ezt Ć*rta:

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


Stefi

export visible rows only
 
Oops, this is the correct code:
Selection.CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy Destination:=Sheets("Sheet2").Range("A1")
Stefi


€˛Stefi€¯ ezt Ć*rta:

Try this code piece (after unwanted cells are hidden):

Selection.CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy Destination:=Sheets("Output").Range("A1").Select


Regards,
Stefi

€˛Cooz€¯ ezt Ć*rta:

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



All times are GMT +1. The time now is 10:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com