Results 1 to 2 of 2

Thread: Deletion of rows in excel

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2004
    Location
    U.K
    Posts
    752

    Deletion of rows in excel

    Hi

    I was hoping someone could help me out here please, basically I have rows and rows of data in Excel, in column H some cells start with __INVALID - so would it be possible to run a macro which would delete the whole row? So basically search and delete all rows where column c = __INVALID.

    Thanks
    Please mark threads as resolved once the problem has been solved.
    I apprecaite all your help/advice given

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Deletion of rows in excel

    vb Code:
    1. Sub FindText()
    2.     Dim rng1 As Range, cell As Range, SrchString As String
    3.    
    4.     Application.ScreenUpdating = False
    5.    
    6.     '~~> Change this to the relevant Column
    7.     Set rng1 = Range("A:A")
    8.     SrchString = "__INVALID"
    9.  
    10.     For Each cell In rng1
    11.         '~~> I am searching for words starting with "__INVALID"
    12.         '~~> Change this as per your requirememnt. For example
    13.         '~~> If you want to check for "__INVALID" at any position
    14.         '~~> in the cell then use Instr()
    15.         If UCase(Left(Trim(cell.Value), 9)) = SrchString Then
    16.             '~~> Delete Row
    17.             Rows(cell.Row).Delete Shift:=xlUp
    18.         End If
    19.     Next
    20.    
    21.     Application.ScreenUpdating = True
    22. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width