Formatting date brought in from another cell?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
Good morning. I'm using this code to populate a cell with a date from another cell:

VBA Code:
Sheets("Calendar").Range("P" & ActiveCell.Row).Value = Sheets("Calendar").Range("DB" & ActiveCell.Row).Text

The source date in column DB is formatted as such: 8/31/2022 7:47 AM

When it displays in column P I need it to be formatted like this: 8/31

I tried variations of this without luck:

VBA Code:
Sheets("Calendar").Range("P" & ActiveCell.Row).Value = Sheets("Calendar").Range("DB" & ActiveCell.Row).Text, Format("M/D")
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Maybe this?:

VBA Code:
    Sheets("Calendar").Range("P" & ActiveCell.Row).Value = Sheets("Calendar").Range("DB" & ActiveCell.Row).Text
   
    ActiveCell.NumberFormat = "M/D"
 
Upvote 0
This does not work:

VBA Code:
    Sheets("Calendar").Range("P" & ActiveCell.Row).Value = "'" & Sheets("Calendar").Range("DB" & ActiveCell.Row).Value
    
    ActiveCell.NumberFormat = "M/D"
 
Upvote 0

Forum statistics

Threads
1,216,090
Messages
6,128,765
Members
449,467
Latest member
sdafasfasdf

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