![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I recorded a Marco to copy filtered data, the filtered data was 26 rows but the recorder copied 724 rows, is there a way to copy just the “visible” data from the auto filter?
|
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Try this:
Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Hope this helps. Cheers, Nate |
|
|
|
|
|
#3 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
...Or along the same lines
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Copy _ Destination:=Sheet10.Range("A1") |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
I am using the code below to copy the auto filleted data, but the new workbook is over 2MB! What is happening the file it is coping form is only 244KB, the auto filter is only showing 12 rows
Sub move_to_new_workbook() Application.ScreenUpdating = False Dim CurrentFileName As String Dim NewFileName As String CurrentFileName = ActiveWorkbook.Name Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Workbooks.Add Template:="Workbook" NewFileName = ActiveWorkbook.Name Range("A1").Select ActiveSheet.Paste Application.CutCopyMode = False Workbooks(CurrentFileName).Activate Application.CutCopyMode = False Range("A1").Select Application.ScreenUpdating = True End Sub |
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Try Dave's code shown below (in this post), you're not making a selection in your code, so it's selecting the entire sheet, bringing the entire sheet, filter, format, null values, etc...And it's making it large.
Sub move_to_new_workbook() Application.ScreenUpdating = False Dim CurrentFileName As String Dim NewFileName As String CurrentFileName = ActiveWorkbook.Name ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Copy Workbooks.Add Template:="Workbook" NewFileName = ActiveWorkbook.Name Range("A1").Select ActiveSheet.Paste Application.CutCopyMode = False Workbooks(CurrentFileName).Activate Application.CutCopyMode = False Range("A1").Select Application.ScreenUpdating = True End Sub Hope this helps. Cheers, Nate [ This Message was edited by: NateO on 2002-03-12 10:32 ] |
|
|
|
|
|
#6 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Try
Sub move_to_new_workbook() Application.ScreenUpdating = False Sheets.Add().Name = "New Data" Selection.SpecialCells(xlCellTypeVisible).Copy _ Destination:=Sheets("New Data").Range("A1") Sheets("New Data").Move ThisWorkbook.Activate Application.ScreenUpdating = True End Sub |
|
|
|
|
|
#7 |
|
Guest
Posts: n/a
|
tried the one by dave only copied on cell
|
|
|
|
#8 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
I meant the code I typed out/copied, using Dave's earlier post. Or you can try this:
Sub move_to_new_workbook() Application.ScreenUpdating = False Dim CurrentFileName As String Dim NewFileName As String CurrentFileName = ActiveWorkbook.Name range("a1:z5000").select 'select appropriate range here Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Workbooks.Add Template:="Workbook" NewFileName = ActiveWorkbook.Name Range("A1").Select ActiveSheet.Paste Application.CutCopyMode = False Workbooks(CurrentFileName).Activate Application.CutCopyMode = False Range("A1").Select Application.ScreenUpdating = True End Sub Hope this helps. Cheers, Nate [ This Message was edited by: NateO on 2002-03-12 10:19 ] |
|
|
|
|
|
#9 |
|
Guest
Posts: n/a
|
NateO, sorry did not see the code the one you had below works. Thanks
Sub move_to_new_workbook() Application.ScreenUpdating = False Dim CurrentFileName As String Dim NewFileName As String CurrentFileName = ActiveWorkbook.Name ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Copy Workbooks.Add Template:="Workbook" NewFileName = ActiveWorkbook.Name Range("A1").Select ActiveSheet.Paste Application.CutCopyMode = False Workbooks(CurrentFileName).Activate Application.CutCopyMode = False Range("A1").Select Application.ScreenUpdating = True End Sub |
|
|
|
#10 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Hey no problemo Anon, all's well that ends well. Happy trails!
Cheers, Nate |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|