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?
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

al_b_cnu

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

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

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,778
Messages
5,513,389
Members
408,949
Latest member
timeisanelephant77

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top