+ Reply to Thread
Results 1 to 6 of 6

Macro to delete rows

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-24-2006
    Location
    INDIA
    MS-Off Ver
    office 2010
    Posts
    190

    Macro to delete rows

    Hello.

    Can anyone please help me in writing the macro, I have a work book with all the customer invoices information, that is very big file and we are maintaining the cumulative data . Let me explain the internal process, some time finance team is holding some hours with some specific reason, once it is solved they will bill the remaining hours. Now my question is I want to check the Hours variance column first and delete the repeated “+” and “– “Hours (AH3 cell “+44” hours and AH8 Cell “-44” hours, project ID and Sales month and Customer is same) and the condition is if project id, sales month and customer is matching

    E-Column – Project ID
    F-Column – Sales Month
    R-Column – Customer
    AH-Column – Hours Variance

    Intention of requesting the macro help is we want to concentrate on not billed cases only, it is very difficult to check manually each entries

    As per the attached file macro should delete S.No 1 and 6 to 10 rows

    Hope it is clear

    Attached the sample data for more clarifications


    Regards
    Sagar
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello sagar,

    Do you want the entire row deleted or simply cleared? Also, would it be acceptable to have the unique data copied onto another worksheet?

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    10-24-2006
    Location
    INDIA
    MS-Off Ver
    office 2010
    Posts
    190
    Hello Leith Ross,

    not a problem to delete the entire row, we are running the macro in Save as file only, master data will be there.

    hope it is clear

    Regards
    Sagar

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello sagar,

    I have added the following macro to the attached workbook. This will show only the unbilled hours.
    Sub ShowUnbilledHours()
    
      Dim Cell As Range
      Dim DSO As Object
      Dim Rng As Range
      
        Application.ScreenUpdating = False
        Set DSO = CreateObject("Scripting.Dictionary")
        
        Set Rng = ActiveSheet.UsedRange.Offset(2, 0)
        Set Rng = Rng.Resize(RowSize:=Rng.Rows.Count - 2)
        
          For Each Cell In Rng.Columns(33).Cells
            If Cell <> "" Then
              If Not DSO.Exists(Abs(Cell)) Then
                 DSO.Add Abs(Cell), Cell.Address
              Else
                 Range(DSO(Abs(Cell))).EntireRow.ClearContents
                 DSO.Remove Abs(Cell)
                 Cell.EntireRow.ClearContents
              End If
            End If
          Next Cell
        
          On Error Resume Next
            Set Rng = Rng.SpecialCells(xlCellTypeBlanks)
            If Err = 0 Then
               Rng.Delete
            End If
            
        Application.ScreenUpdating = True
        Set DSO = Nothing
       
    End Sub
    To Run the Macro...
    To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

    Sincerely,
    Leith Ross
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    10-24-2006
    Location
    INDIA
    MS-Off Ver
    office 2010
    Posts
    190
    Thanks a lot for your help, perfectly working

    Regards
    Sagar

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ Reply to Thread

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