PDA

View Full Version : Creating index sheet in excel. Help



kevvukeka
05-19-2013, 10:50 PM
Hi All,

I need some help with the below code. I want to use this one to make an index sheet. The below code basically extracts all the sheet names in the workbook to a new sheet. There are few sheets that are hidden and i dont want those sheet names in index. so wrote the macro as below. But i still see blank rows.



sub index()





Sheets("Sheet").Select
Sheets.Add
For I = 1 To Sheets.Count


If (Sheets(I).Visible) = True Then
With ActiveSheet.Cells(I, 1)
.Value
= CStr(Sheets(I).Name)
End With
End If
Next I


ActiveSheet.UsedRange.Select
For Each cel In Selection
If cel.Value =
"" Then
cel.EntireRow.select
Selection.Delete Shift:=xlUp


End If
Next cel
selection.end(xlup).select


end sub


Thanks & Regards,
Praveen

SamT
05-20-2013, 12:11 AM
Sub index()
'Assumes Sheet("Index") exists

Dim Sht As Sheet
Dim Rw As Long
Rw = 1

With Sheets("Index")
For Each Sht in Sheets
If Sht.Name = "Index" Then GoTo SkipThisSht
If Sht.Visible) = True Then .Cells(Rw, 1) = Sht.Name
Rw = Rw + 1
SkipThisSht:
Next Sht

End Sub

kevvukeka
05-20-2013, 01:36 AM
Thanks so much SAM