VBA Specific Value to Return with Date Calculation

Razor_Rob

Board Regular
Joined
Aug 18, 2022
Messages
63
Office Version
  1. 365
Platform
  1. Windows
Hi
Need help with VBA please
I would like to Return 2 values to Column A
1stHalf
2ndHalf

If current date is on or after 1st January 2023(Current Year) BUT before 1st July 2023(following year) make the used rows in Column A to have a value "1stHalf"
If current date is on or after 1st July 2022 (Current Year) BUT before 1st January 2023(following year) make the used rows in Column A to have a value "2ndHalf"


Thanks in advance
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Are you really wanting to use the "Current Date", or is their some data field we should be looking in (if so, where is it)?

If you really just want to use the current date, you could simply use this formula:
Excel Formula:
=IF(MONTH(TODAY())<7,"1stHalf","2ndHalf")
 
Upvote 0
How do I convert that to a VBA as I've got other codes and I can just add that in my existing vba
 
Upvote 0
How do I convert that to a VBA as I've got other codes and I can just add that in my existing vba
Something like this:
VBA Code:
    If Month(Date) < 7 Then
        Range("A1") = "1stHalf"
    Else
        Range("A1") = "2ndHalf"
    End If
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

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