Title New Column Text plus Today's Date

CJG19

New Member
Joined
Jul 12, 2021
Messages
40
Office Version
  1. 2010
Platform
  1. Windows
Good Afternoon,

I wonder if anyone would be able to help.

I am writing a macro that adds a column to the end of a table, then renames that column with "Remaining PO DD-MMM-YY" with DD-MMM-YY being today's date. Previous columns will be kept, so I have to navigate to the cell.

I have got to this, but it doesn't seem to be working. I know it is probably something easy but I keep getting the attached error message.

VBA Code:
Sub Add_New()

    LDate = Format(Date, "dd-mmm-yy")
 
  Range("A3").End(xlToRight).Select
    ActiveCell.Name = "Remaining PO" & " " & LDate
 
End Sub

Thank you in advance

CJG19
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
It should be:
VBA Code:
ActiveCell.Value
not
VBA Code:
ActiveCell.Name

Note that you can just combine these two lines:
VBA Code:
  Range("A3").End(xlToRight).Select
    ActiveCell.Value = "Remaining PO" & " " & LDate
to this:
VBA Code:
  Range("A3").End(xlToRight).Value = "Remaining PO " & LDate

Or even better, all your code could be combined to a single line:
VBA Code:
  Range("A3").End(xlToRight).Value = "Remaining PO " & Format(Date, "dd-mmm-yy")
 
Upvote 1
Solution
Hey Joe4,

Amazing, thank you so much for your help! 😃

CJG19
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 1

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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