![]() |
Naming a sheet from formula result
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 |
Naming a sheet from formula result
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) -- HTH Bob Phillips "Rob" wrote in message ... 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 |
Naming a sheet from formula result
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) "Bob Phillips" wrote in message ... 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) -- HTH Bob Phillips "Rob" wrote in message ... 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 |
Naming a sheet from formula result
of course ... should have spotted that :-)
Bob "Rob" wrote in message ... 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) "Bob Phillips" wrote in message ... 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) -- HTH Bob Phillips "Rob" wrote in message ... 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 |
All times are GMT +1. The time now is 11:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com