LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default For Next Loop to Make A4 in Each Sheet = Name of Each Tab

Im trying to run a (somewhat) simple procedure, but not getting the results
I am seeking. I have one sheet named Control Sheet and I am running the
macro from here. I am trying to insert a column into each of the other
sheets in the workbook (all sheets not named Control Sheet) and then get
the name of each sheet in cell A4 of each sheet. Sounds simple enough,
right. I played with the code below a little, but cant get it to do what I
want it to do. I keep getting a message that says Next Without For, but I
thought I had the For and Next structured properly. Argh!! Any help would
be MUCH appreciated. TIA!

Sub ListNames()
Dim sh As Worksheet
Dim xs As Integer

For Each sh In ActiveWorkbook.Worksheets

If LCase(sh.Name) < "Control Sheet" Then
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A3").Select
ActiveCell.FormulaR1C1 = "Tab Name"

For xs = 1 To Worksheets.Count
Worksheets(xs).Range("A4").Value = Worksheets(xs).Name
Next xs
Next sh

End If
Next
End Sub

--
RyGuy
 
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
Can't make loop macro work - help? [email protected] Excel Programming 1 October 11th 06 03:23 PM
How can I make For-Next loop with date? GreenInIowa Excel Programming 5 October 14th 05 05:10 PM
How can I make For-Next loop with date? JS2004R6 Excel Programming 0 October 14th 05 05:20 AM
I want to make one loop David Excel Programming 2 October 12th 05 01:35 AM
How to Make a Loop count by 1% not 1 MichaelC Excel Programming 8 June 12th 05 02:04 AM


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