ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro - Format Spreadsheet (https://www.excelbanter.com/excel-programming/308455-re-macro-format-spreadsheet.html)

Dave Peterson[_3_]

Macro - Format Spreadsheet
 
One way to do #1:

Option Explicit
Sub testme01()

Dim rngSearch As Range
Dim rngFound As Range

With Worksheets("sheet1")
Set rngSearch = .Cells 'or .range("a:a") or .range("a:e")
With rngSearch
Do
Set rngFound = .Find("premium", LookIn:=xlValues, _
lookat:=xlWhole, searchdirection:=xlNext, _
MatchCase:=False)

If rngFound Is Nothing Then
Exit Do
Else
rngFound.EntireRow.Delete
End If
Loop
End With
End With

End Sub

And for #2. It's probably easiest to just record a macro when you do it
manually.

Select your range, then Data|sort

After the sort, select the range, then Data|Subtotals

It won't insert two blank rows, but using excel's builtin functions may make
your life a lot easier.



ACase wrote:

Hello,

I want to format a spreadsheet and need to do 2 things via a macro.

1) Search for a particular string "Premium" and delete all rows with this
value

2) Sort on 3 fields (Underlying, Trade Type, and BuySell) add two blank
lines whenver there is a change in the above three, and subtotal on Position.

Any help would be much appreciated.

Thanks
ACase


--

Dave Peterson



All times are GMT +1. The time now is 05:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com