Create a String to Use as a Range Name - Illegal Characters

Shiseiji

Board Regular
Joined
Oct 23, 2009
Messages
214
Office Version
  1. 2019
Platform
  1. Windows
The problem, I think, is that I'm ending up with illegal characters so can't use the string as a range name and I don't know where the characters are being inserted. I also understand a UDF can be created to clean the string, but I simply can't figure out to use the UDF with VBA.

Help.

TIA

Code:
Dim tCell                   As Range
Set tCell = Cells(1, LastCol).Offset(0, 1)
With tCell
        .NumberFormat = "mm-dd-yyyy"
        .FormulaR1C1 = "=""User_"" & TEXT(TODAY(),""mm-dd"")"
        .Copy
        .PasteSpecial xlPasteValues
        .NumberFormat = "@"
  End With
tCell.Name = tCell

I've also tried .Value = .Value


Ron
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try
Code:
Dim tCell                   As Range
Set tCell = Cells(1, LastCol).Offset(0, 1)
tCell.Value = "User_" & Format(Date, "mm_dd")
tCell.Name = tCell
 
Upvote 0
Solution
Success! KISS, got to love it. Focusing too much learning how to avoid "Activate" & "Select" that I've obviously using it where a KISS is much better.

Thanks much.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
I value the help too much to not show appreciation. I do my volunteering in a bicycle coop and value the thanks I get. So many here give so much more. My join date shows '09, but that's because till then I found what I needed without asking since probably 2000????? seems like that long ago anyway.

As a Soldier, what I learned here was invaluable after 9-11 for managing deployment schedules. No where near as automated as many would assume, I had to filter, sort, compare, and then report out on data dumps 2 a day for months to be sure the troops were ready when the planes were coming. You never know how far a quick post here will go. Now that I'm retired I can say that the whole time I thought, "This is insane, the country has no idea what we are getting ourselves into. Or how hard it is going to be to get out . . . . "

Ron
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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