Macro code/script

EMister

New Member
Joined
Jan 23, 2025
Messages
1
Office Version
  1. 365
Platform
  1. Windows
hi guys,

the below script is the first macro I run, how should I update the script to run similar data like below? I need to delete the entire row with the text "sub total" in column A. the original file has Sub total in row 22 and row 83.

any tips or tricks how to do it?

Asset GroupTransaction DescriptionShares/Par
FUTUREPURCHASE FUTURE1.000
FUTUREPURCHASE FUTURE6.000
FUTUREPURCHASE FUTURE45.000
FUTUREPURCHASE FUTURE7.000
Sub TotalFUTURE79.000
STOCK MARKETSALE ON STOCK MARKET8,504.000
STOCK MARKETSALE ON STOCK MARKET9,978.000
STOCK MARKETSALE ON STOCK MARKET86.000
STOCK MARKETSALE ON STOCK MARKET529.000
Sub TotalSTOCK MARKET12,515,072.000

Sub TGL_salesjournal()
'
' TGL_salesjournal Macro
'

'
Rows("22:22").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=51
Rows("83:83").Select
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-51
Range("B8:C17").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Selection.End(xlToRight).Select
Range("X8").Select
ActiveSheet.Paste
Range("V8:W8").Select

thank you
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try the code below on a copy of your data

VBA Code:
Sub Filterit()
    Application.ScreenUpdating = False
    
    With Range("A1:D" & Range("A" & Rows.Count).End(xlUp).Row)
    
        .AutoFilter 1, "Sub Total"
        
        On Error Resume Next
        With .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
            .EntireRow.Delete
        End With
        On Error GoTo 0
        ActiveSheet.ShowAllData
    
    End With
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,226,067
Messages
6,188,700
Members
453,493
Latest member
BRACE

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