Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I would like to loop through all th

Status
Not open for further replies.

carmo

MIS
Dec 15, 2002
92
CA
I would like to loop through all the cells in a worksheet. Where ever there is a cell the equals "current", delete that row. Can someone help me get started with created a VBA macro. Thanks.

Carmo
 
Hiya carmo,


This should get you on your way:

Code:
    Dim l_wksSheet As Worksheet
    Dim l_rngCells As Range
    Dim cell As Range
    
    Set l_wksSheet = ThisWorkbook.Sheets("NameOfSheet")
    Set l_rngCells = l_wksSheet.UsedRange
    
    For Each cell In l_rngCells
        If cell.Value = "current" Then cell.EntireRow.Delete
    Next cell

    Set l_rngCells =nothing
    Set l_wksSheet = Nothing
/code]

Just substitute [b]NameOfSheet[/b] with the name of the sheet you want to loop through


HTH 

Cheers
Nikki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top