Not the best with VBA

nathan663

Board Regular
Joined
Dec 3, 2008
Messages
153
I have recorded a macro, and edited it to as it is below:


Sheets.Add.Name = "Minor" 'Add Worksheets - with titles'
Sheets.Add.Name = "Fire Chargeable"
Sheets.Add.Name = "Fire Non Chargeable"
Sheets.Add.Name = "Chargeable"
Sheets.Add.Name = "Non Chargeable"
Sheets("Sheet 1").Select
Rows("1:1").Select
Selection.AutoFilter 'add filter'
Range("G2").Select
ActiveWindow.FreezePanes = True 'Freeze Pane'
Range("G5").Select
Selection.AutoFilter Field:=3, Criteria1:="MWK"
Rows("24:32").Select
Selection.Cut
Sheets("Minor").Select
Range("A2").Select
ActiveSheet.Paste
Sheets("Sheet 1").Select
Selection.AutoFilter Field:=3 'Close Filter'
Selection.AutoFilter Field:=27, Criteria1:="=CCTV*", Operator:=xlOr, _
Criteria2:="=ACC*" 'Filter for ACC and CCTV'
Rows("02:50").Select
Selection.Cut 'ONLY CUT ROWS THAT ARE VISIBLE'
Sheets("Chargeable").Select
Range("A2").Select
ActiveSheet.Paste
Range("B11").Select
Sheets("sheet 1").Select
Rows("1:1").Select
Selection.Copy
Sheets("Chargeable").Select
Rows("1:1").Select
ActiveSheet.Paste
Sheets("Fire Non Chargeable").Select
Rows("1:1").Select
ActiveSheet.Paste
Sheets("Fire Chargeable").Select
Rows("1:1").Select
ActiveSheet.Paste
Sheets("Minor").Select
Rows("1:1").Select
ActiveSheet.Paste
Sheets("Non Chargeable").Select
Rows("1:1").Select
ActiveSheet.Paste

where i have added a notation 'ONLY CUT ROWS THAT ARE VISIBLE'... How do i do this??? what code should i add.

Also can any one help me tidy this code up a little?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

al_b_cnu

Well-known Member
Joined
Jul 18, 2003
Messages
4,526
Hi,

Try
Code:
Rows("2:50").SpecialCells(xlCellTypeVisible).Delete
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,612
Messages
5,832,697
Members
430,154
Latest member
Froggy16

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
Top