Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am completely new to macros so please accept my
apologies if what i am asking is very basic. I have a spreadsheet full of data (sheet1). I want to delete all rows in the spreadsheet that do not contain the word "Total" in column A. I want to know how to do this if: i) Any part of the cell contains the word "Total" ii) The cell only contains the word "Total" (and nothing else) Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim rng As Range, i As Long With ActiveSheet For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row If LCase(.Cells(i, 1).Value) Like "*total*" Then If rng Is Nothing Then Set rng = Rows(i) Else Set rng = Union(rng, Rows(i)) End If Next If Not rng Is Nothing Then rng.Delete xlShiftUp End With End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Sean" wrote in message ... I am completely new to macros so please accept my apologies if what i am asking is very basic. I have a spreadsheet full of data (sheet1). I want to delete all rows in the spreadsheet that do not contain the word "Total" in column A. I want to know how to do this if: i) Any part of the cell contains the word "Total" ii) The cell only contains the word "Total" (and nothing else) Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A macro for deleting lines of text | Excel Worksheet Functions | |||
Deleting unused lines between used lines? | Setting up and Configuration of Excel | |||
Deleting Lines in Excel | Excel Discussion (Misc queries) | |||
Deleting lines with no data | Excel Programming | |||
Deleting lines really deletes lines! | Excel Programming |