Results 1 to 6 of 6

Need VBA Code for Adding / Deleting Rows

Threaded View

  1. #1
    Registered User
    Join Date
    03-09-2012
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Need VBA Code for Adding / Deleting Rows

    Ok - I have 2 parts that I need for Adding / Deleting Rows to a formula based worksheet. (If you can find a simplier option, I would appreciate)

    Part 1 - VBA CODE - Based on a value in a cell ("ADD")(Column R) - copy the row above and insert copied cells (shift cells down) - Need to loop until "NO ADD") (need help with formula for the cell to get "ADD" - I have ****=IF(AND(ISTEXT(A9),ISNUMBER(A8)),"ADD","NO ADD") **** However when new row is copied down I get ****=IF(AND(ISTEXT(A10),ISNUMBER(A8)),"ADD","NO ADD") **** Again the copying needs to loop but ISNumber(stays the same) needs to be one less than ISTEXT()

    Part 2 - This is the code I have to delete the rows and it works

    Sub DELETEROWS()
        Dim Firstrow As Long
        Dim Lastrow As Long
        Dim Lrow As Long
        Dim CalcMode As Long
        Dim ViewMode As Long
    
        With Application
            CalcMode = .Calculation
            .Calculation = xlCalculationManual
            .ScreenUpdating = False
        End With
    
        With ActiveSheet
    
    
            Firstrow = 5
            Lastrow = 500
    
            For Lrow = Lastrow To Firstrow Step -1
    
                With .Cells(Lrow, "Q")
    
                    If Not IsError(.Value) Then
    
                        If .Value = "DELETE" Then .EntireRow.Delete
                        'This will delete each row with the Value "delete"
                        'in Column Q, case sensitive.
    
                    End If
    
                End With
    
            Next Lrow
    
        End With
    
        
        With Application
            .ScreenUpdating = True
            .Calculation = CalcMode
        End With
    Attached Files Attached Files
    Last edited by sambuka; 06-26-2012 at 10:56 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1