Consulting

Results 1 to 2 of 2

Thread: VBA code to count number of only weekdays between 2 dates

  1. #1

    VBA code to count number of only weekdays between 2 dates

    Hi All,

    I need VBA code for the below situation.

    i have 2 days in 2 columns

    ColumnA ColumnB
    09-July-2018 06-July-2018
    09-July-2018 04-July-2018

    So if Column B date is less than 2 working days, then the complete row should be delete.

    Regards,
    Anantha Krishna

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Sub test()
    
        Application.ScreenUpdating = False
    
        With Cells(1).CurrentRegion.Columns(3)
            .Formula = "=networkdays(b1,a1)"
            .Value = .Value
        End With
        
        Rows(1).Insert
        With Cells(1).CurrentRegion.Columns(3)
            .AutoFilter 1, "<2"
            If .SpecialCells(xlCellTypeVisible).Count > 1 Then
                .Offset(1).EntireRow.Delete
            End If
            .AutoFilter
            .ClearContents
        End With
        Rows(1).Delete
    
    End Sub

Tags for this Thread

Posting Permissions

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