To check if Last working day of month was a Friday.

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi All,

In my Excel App, for our monthly report, I need to set the value of a column based on a date column (B).
If the dates in col B are the last working day of the month and happens to be a Friday then values in col BA should 3.
For example, in Col B, the dates are 03/31/03 and is a Friday, how to derive the value.

Since April 28 will also be the last working day and Friday, i need to get this .
How to determine if the last working day is a Friday or not?

TIA
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Look at the Weekday() function.
Does depend on your starting day.
 
Upvote 0
Look at the Weekday() function.
Does depend on your starting day.
I tried this but got an error

VBA Code:
    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
        If Weekday(ws.Range("B" & i).Value = 5, True, False) = True Then
            ws.Range("BG" & i).Value = "3"
        End If
    Next i

1680790157617.png
 
Upvote 0
Try
VBA Code:
If Weekday(ws.Range("B" & i).Value)=6 Then
 
Upvote 0
6 is for Friday?
Is this correct,

VBA Code:
    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
        If Weekday(ws.Range("B" & i).Value) = 6 Then
            ws.Range("BG" & i).Value = "3"
        End If
    Next i
 
Upvote 0
Here is excel formulas:
Book1
ABA
1
2Sat, 2023-02-25 
3Sun, 2023-02-26 
4Mon, 2023-02-27 
5Tue, 2023-02-28 
6Wed, 2023-03-01 
7Thu, 2023-03-02 
8Fri, 2023-03-03 
9Mon, 2023-03-27 
10Tue, 2023-03-28 
11Wed, 2023-03-29 
12Thu, 2023-03-30 
13Fri, 2023-03-313
14Sat, 2023-04-01 
15Sun, 2023-04-02 
16Wed, 2023-04-26 
17Thu, 2023-04-27 
18Fri, 2023-04-283
19Sat, 2023-04-29 
20Sun, 2023-04-30 
21Mon, 2023-05-01 
22Tue, 2023-05-02 
Sheet1
Cell Formulas
RangeFormula
BA2:BA22BA2=IF(AND(WEEKDAY(A2)=6,DAY(WORKDAY.INTL(A2,1))<=3),3,"")
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,948
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top