Naming a sheet from formula result

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I would like to name a sheet from the result of a formula that gets is
result from a cell in a worksheet, the following is my routine but first
writes the formula to cell A1 in the worksheet, is there a more appropriate
method?

Dim shname As String
Range("A1").Formula = _
"=""DD""&Left(Right(A2, 10), 2) & Right(B2, 6)"
shname = Range("A1").Value
Range("A1").ClearContents
Sheets(1).Name = shname

Thanks, Rob
 
I don't think you need a formula as there are VBA Left and Right methods. So
how about


Sheets(1).Name = "DD" & Left(Right(A2, 10), 2) & Right(B2, 6)
 
Bob,

Thanks for this, I amended to include Range so as I had set Options Explicit

Sheets(1).Name = "DD" & Left(Right(Range("A2"), 10), 2) &
Right(Range("B2"), 6)
 
of course ... should have spotted that :-)

Bob

Rob said:
Bob,

Thanks for this, I amended to include Range so as I had set Options Explicit

Sheets(1).Name = "DD" & Left(Right(Range("A2"), 10), 2) &
Right(Range("B2"), 6)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top