Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


I have a file that i do not know how many sheet are there in before

i need to copy contain of C4 to name of sheets

Thank for your help.


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347

  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,593
Default How to use VBA to name sheet ?


For Each sh In Activeworkbook.Worksheets

sh.Name = sh.Range("C4").Value

Next sh

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"vumian" wrote in
message ...

I have a file that i do not know how many sheet are there in before

i need to copy contain of C4 to name of sheets

Thank for your help.


--
vumian
------------------------------------------------------------------------
vumian's Profile:

http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


hi,

sorry, i fail to understand your mean

Could you be more specific,pls

Thank you.


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 427
Default How to use VBA to name sheet ?

Create and run that macro.

Will do the job.

Unless you left something out of the original query.

Steve



On Tue, 25 Jul 2006 16:02:59 +0100, vumian
wrote:


hi,

sorry, i fail to understand your mean

Could you be more specific,pls

Thank you.

  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


thanks your idea, but here can not create macro coz i do not know how
many sheet before ?

How to use For statement here ?
VBA only.

thanks for your help.


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347



  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 427
Default How to use VBA to name sheet ?

Why VBA only,

Anyway I count Excel macros as VBA

"For Each sh In Activeworkbook.Worksheets"

That does the counting for you.


On Tue, 25 Jul 2006 16:19:26 +0100, vumian
wrote:


thanks your idea, but here can not create macro coz i do not know how
many sheet before ?

How to use For statement here ?
VBA only.

thanks for your help.


  #7   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


Dim sh As Worksheets
Sub GetName()
For Each sh In ActiveWorkbook.Worksheets
sh.Name = sh.Range("C4").Value
Next sh
End Sub


It do not run.
Why, help me pls


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347

  #8   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 427
Default How to use VBA to name sheet ?

Works perfectly without the Dim statment - not needed

Steve

On Tue, 25 Jul 2006 16:57:09 +0100, vumian
wrote:


Dim sh As Worksheets
Sub GetName()
For Each sh In ActiveWorkbook.Worksheets
sh.Name = sh.Range("C4").Value
Next sh
End Sub


It do not run.
Why, help me pls





--
Steve (3)
  #9   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


thank you very much, so great. man :)


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347

  #10   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 10,593
Default How to use VBA to name sheet ?

I would advise against suggesting that variables are not declared, poor
programming practice. The problem is that it should be declared as Worksheet
against Worksheets, not that it shouldn't be declared.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"SteveW" wrote in message
news:op.tc88mtjcevjsnp@enigma03...
Works perfectly without the Dim statment - not needed

Steve

On Tue, 25 Jul 2006 16:57:09 +0100, vumian
wrote:


Dim sh As Worksheets
Sub GetName()
For Each sh In ActiveWorkbook.Worksheets
sh.Name = sh.Range("C4").Value
Next sh
End Sub


It do not run.
Why, help me pls





--
Steve (3)




  #11   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 427
Default How to use VBA to name sheet ?

Quite right Bob,

Just the end of a long line of replies :)

On Wed, 26 Jul 2006 09:19:39 +0100, Bob Phillips
wrote:

I would advise against suggesting that variables are not declared, poor
programming practice. The problem is that it should be declared as
Worksheet
against Worksheets, not that it shouldn't be declared.




--
Steve (3)
  #12   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default How to use VBA to name sheet ?


hi everyone,

with code above, there is a error as following:

if value of C4 of every sheet same, it can not run code above.

how to msgbox in case

Sub GetName()
For Each sh In ActiveWorkbook.Worksheets
sh.Name =3D sh.Range("C4").Value
if .... What is it here to msgbox, pls
Next sh
End Sub


--
vumian
------------------------------------------------------------------------
vumian's Profile: http://www.excelforum.com/member.php...o&userid=36494
View this thread: http://www.excelforum.com/showthread...hreadid=564347

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
Sum up columns in different sheet with error check zeyneddine Excel Discussion (Misc queries) 13 July 10th 06 01:21 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
lock tab in sheet 2 until cell in sheet one is completed john tempest Excel Worksheet Functions 7 November 24th 05 08:45 AM
Using a relative SHEET reference for source data in a chart James Charts and Charting in Excel 6 August 16th 05 05:07 PM
linking multiple sheets to a summary sheet greg g Excel Discussion (Misc queries) 1 December 16th 04 07:43 AM


All times are GMT +1. The time now is 12:09 PM.

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

About Us

"It's about Microsoft Excel"