View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
T De Villiers[_3_] T De Villiers[_3_] is offline
external usenet poster
 
Posts: 1
Default Placing Workshet Name in cells


Hi,

I have 50 worksheets in a workbook,

For each, i need to:

1) Insert a Column at far left
2) For each cell in this Col I need to place the value of th
Worksheet Name

So if there are 127 used rows, and the Worksheet Name is 100100
A1:A127 need to all be populated with the value 100100

My code below doesn't quite work, any tweaking is much appreciated.

Many Thanks


Sub ins()
For Each wks In Worksheets

On Error Resume Next
Dim i
Dim LastRow As Long

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
LastRow = Cells(Rows.Count, 2).End(xlUp).Row

For i = 1 To LastRow
Cells(i, 1) = Worksheet.Name
Next

End Su

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=46945