how to select multiple columns with visible cells only - simple code

ikhan123

Board Regular
Joined
Mar 20, 2013
Messages
89
Hi,

i have a table and i want to filter then select multiple columns with visible cells only coz it take to much time to paste.

i want speed and simple coding to do this and i have large database (~1000000) but filter data is only (~300).

below example table started at A2 (A1 = title):

1azTemp
1azTemp
1azTemp
1azTemp
2czaData
2czaData
2czaData
3fxdData1
3fxd1Data1
1a1z12Data74
2CDvbacode1
1s1xaData1
3dd12Data1
44545Data145

<tbody>
</tbody>

Code:
Sub Macro2()

    Range("A1").select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$F$500").AutoFilter Field:=1, Criteria1:="1"
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
'''repeated
    Range("B1").Select
    ActiveSheet.Previous.Select
    Range("D1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveSheet.Next.Select
    ActiveSheet.Paste
    Range("C1").Select
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Selection.AutoFilter
    Range("A1").Select


End Sub

FYI: if i filter data and then select only visible rows (may be 5 or 8) with columns (A & D) it should only take visible rows.


hope i am clear with my question.


Thanks,
ikhan123
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
instead of vba code, did you try the built-in function in Excel? which is Go to Special, visible cell only

Selection.SpecialCells(xlCellTypeVisible).Select
this is the code from Macro recorder. just in case you need it.
 
Last edited:
Upvote 0
instead of vba code, did you try the built-in function in Excel? which is Go to Special, visible cell only

Selection.SpecialCells(xlCellTypeVisible).Select
this is the code from Macro recorder. just in case you need it.


Sorry. I am new in excel and am not aware of function in excel.

it would be great if you'll provide me the code.

Thank you in advance
 
Upvote 0

Forum statistics

Threads
1,214,531
Messages
6,120,073
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top