Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Renaming Worksheet

Hello all,

I have the following problem which I'd like to solve with a macro. Is it
possible to run a macro that renames the worksheet with the text I put in
this worksheet in cell B1, e.g.? I hope there is a solution.

Thanx for your help.

Kind regards,

Noepie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Renaming Worksheet

here are 2 examples, one using activesheet and one using the index number, which
is the first sheet in this case:

Sub rename_sheet()
With Worksheets(1)
..Name = .Range("B1").Value
End With
End Sub

Sub rename_sheet()
With ActiveSheet
..Name = .Range("B1").Value
End With
End Sub


--


Gary

"Noepie" wrote in message
...
Hello all,

I have the following problem which I'd like to solve with a macro. Is it
possible to run a macro that renames the worksheet with the text I put in
this worksheet in cell B1, e.g.? I hope there is a solution.

Thanx for your help.

Kind regards,

Noepie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Renaming Worksheet

Hello Noepie

This is an event code, so it has to be copied into the codesheet for the
desired sheet.
Right click on the desired sheet tab and select "View Code". Paste the code
below.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B1") Then
If Target.Value < "" Then
ActiveSheet.Name = Target.Value
End If
End If
End Sub

Regards,
Per

"Noepie" skrev i meddelelsen
...
Hello all,

I have the following problem which I'd like to solve with a macro. Is it
possible to run a macro that renames the worksheet with the text I put in
this worksheet in cell B1, e.g.? I hope there is a solution.

Thanx for your help.

Kind regards,

Noepie


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Renaming Worksheet

Dear Per / Gary,

Both ways give the desired result, so thanx for helping me out.

Kind regards,

Noepie

"Per Jessen" wrote:

Hello Noepie

This is an event code, so it has to be copied into the codesheet for the
desired sheet.
Right click on the desired sheet tab and select "View Code". Paste the code
below.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B1") Then
If Target.Value < "" Then
ActiveSheet.Name = Target.Value
End If
End If
End Sub

Regards,
Per

"Noepie" skrev i meddelelsen
...
Hello all,

I have the following problem which I'd like to solve with a macro. Is it
possible to run a macro that renames the worksheet with the text I put in
this worksheet in cell B1, e.g.? I hope there is a solution.

Thanx for your help.

Kind regards,

Noepie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet renaming jwilliam33 Excel Discussion (Misc queries) 5 December 6th 08 09:14 PM
Worksheet Renaming Eric Excel Worksheet Functions 1 July 26th 07 02:38 PM
renaming worksheet draganpi Excel Programming 2 April 6th 06 12:06 PM
need help renaming a worksheet jonwyn Excel Discussion (Misc queries) 2 March 1st 05 08:34 PM
Renaming the Worksheet through VBA abxy[_24_] Excel Programming 4 February 9th 04 07:32 PM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"