View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default 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