EXCEL VBA if or

haijaggu143

New Member
Joined
Jan 23, 2019
Messages
4
Hi all,


Please help to run this formula if the day in cell C2 value is saturday

Range("F2").Formula = "=IF(AND(D2>=TIME(9,16,0),D2<=TIME(11,59,0)),D2-TIME(9,0,0),IF(AND(D2>=TIME(14,16,0),D2>=TIME(12,00,0)),D2-TIME(14,0,0)*1,0))"

and if Cell C2 value is Sunday to Friday


Range("F2").Formula = "=IF(AND(D2>=TIME(8,16,0),D2<=TIME(10,30,0)),D2-TIME(8,0,0),IF(AND(D2>=TIME(12,16,0),D2>=TIME(10,31,0)),D2-TIME(12,0,0)*1,0))"



Until the last row which has data in the sheet.

In short check the value in C2, if = saturday formula 1 or formula 2.


Thanks in advance

Jagadeesh Balakrishnan
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
From C2 onwards Column C contains date
05/03/2019
06/03/2019
07/03/2019

<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

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