Mmmm... not really. Sorry. The only change I made was in the way I assembled
what the macro was doing. No significant changes there. The logic for
creating the range is exactly what the macro is doing. The dollar sign thing
I added as a precaution, there were no dollar signs in the range I recorded,
either. Having said this, I will try what you are suggesting. I'm still
stumped, though, by why the apostrophes are added when they are not in the
variables my code is generating. Why is Excel doing that, I am left to
wonder... Anyway, thank you for your help so far. I'll give it a try tonight.
"
"ppsa" wrote:
> In the following code, RangeNamePrefix = "Jul071" and NewSheet.Name = "July,
> 2007 - 1"
>
> ===================================================
> Dim NewRangeName As String
> Dim RefersTo As String
> RangeAddress = Replace(Range("DateValues").Address, "$", "")
> RefersTo = "='" & NewSheet.Name & "'!" & RangeAddress
> NewRangeName = RangeNamePrefix & "DateValues"
>
> ActiveWorkbook.Names.Add Name:=NewRangeName, RefersToR1C1:=RefersTo
> ===================================================
>
> The variables resolve to the following:
> RangeAddress: "A20:A450"
> RefersTo: "='July, 2007 - 1'!A20:A450"
> NewRangeName: "Jul071DateValues"
>
> You would think that after this code runs, the range A20:A450 would be named
> properly, but it's not. When I go to Insert/Name/Define, the range name is
> listed corrctly, but the address is wrong. It has apostrophes around the
> individual cell addresses, like this:
>
> ='July, 2007 - 1'!'A20':'A450'
>
> I'm stumped. Anyone know what's going on here?
>
> Thanks.