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

What is the code to paste the worksheet name in cell "C3" of each worksheet
in the workbook? I tried the following, but it didn't work. Thank you.

Sub insertname()
Dim Rng As Range
Dim n As Integer
Dim y as integer

n = Worksheets.Count
For y = 1 To n
Worksheets(y).Select
Set Rng = Range("A1")
Range("A1").Select
ActiveCell.Offset(0, 3).Value = Sheet.Name
Next y

end sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default Insert Worksheet Names

Hi Filo,

You can try this one:

Sub insertname()
Dim Wks as Worksheet
For each Wks in activeworkbook.sheets
Wks.Range("C3") = Wks.name
Next Wks
End Sub

--

Regards,

Halim


"Filo" wrote:

What is the code to paste the worksheet name in cell "C3" of each worksheet
in the workbook? I tried the following, but it didn't work. Thank you.

Sub insertname()
Dim Rng As Range
Dim n As Integer
Dim y as integer

n = Worksheets.Count
For y = 1 To n
Worksheets(y).Select
Set Rng = Range("A1")
Range("A1").Select
ActiveCell.Offset(0, 3).Value = Sheet.Name
Next y

end sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Insert Worksheet Names

Hi Filo,
Halim's rewrite is, of course, better because the activecell
and the activesheet are not changed so there is no screen
refresh so that is the kind of coding that you want to use.

But yours would probably work had you used
ActiveSheet.Range("C3") = ActiveSheet.Name



"Halim" wrote in message ...
Hi Filo,

You can try this one:

Sub insertname()
Dim Wks as Worksheet
For each Wks in activeworkbook.sheets
Wks.Range("C3") = Wks.name
Next Wks
End Sub

--

Regards,

Halim


"Filo" wrote:

What is the code to paste the worksheet name in cell "C3" of each worksheet
in the workbook? I tried the following, but it didn't work. Thank you.

Sub insertname()
Dim Rng As Range
Dim n As Integer
Dim y as integer

n = Worksheets.Count
For y = 1 To n
Worksheets(y).Select
Set Rng = Range("A1")
Range("A1").Select
ActiveCell.Offset(0, 3).Value = Sheet.Name
Next y

end sub



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
using the Excel generic worksheet names instead of user-given names in code Paul Excel Discussion (Misc queries) 5 June 26th 09 08:44 PM
Insert Worksheet Names into Cells Howardjnl Excel Discussion (Misc queries) 1 December 20th 07 11:25 PM
Selecting ALL names when using Insert/Names/Apply Mike Excel Worksheet Functions 3 April 23rd 05 05:20 PM
I need a macro that will insert names in an excel worksheet, the . Ocicat Excel Programming 1 November 16th 04 06:04 PM
return all worksheet tab names and chart sheet tab names in report - an example DataFreakFromUtah Excel Programming 2 October 6th 04 08:09 PM


All times are GMT +1. The time now is 04:01 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"