Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Column To Column, Row By Row Worksheet name list

I have a workbook that has close to 100 worksheets in it and have come up
with a little this code to list all the worksheet names on a single worksheet
starting at row 2. What I am trying to do is manipulate this code even
further that states to have it list the worksheets from row 2 down to row 30
in column 1, then move over to column 2 and do the same thing from row 2 to
30 and so on till all names have been listed.

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2

For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(1).Value = ws.Name

iRow = iRow + 1

Next

Range("A1").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Column To Column, Row By Row Worksheet name list

Kyer,

try this:

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer, iCol As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2
iCol = 1
For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(iCol).Value = ws.Name

iRow = iRow + 1
If iRow 30 Then
iRow = 2
iCol = iCol + 1
End If

Next

Range("A1").Select
End Sub

"Kryer" wrote:

I have a workbook that has close to 100 worksheets in it and have come up
with a little this code to list all the worksheet names on a single worksheet
starting at row 2. What I am trying to do is manipulate this code even
further that states to have it list the worksheets from row 2 down to row 30
in column 1, then move over to column 2 and do the same thing from row 2 to
30 and so on till all names have been listed.

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2

For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(1).Value = ws.Name

iRow = iRow + 1

Next

Range("A1").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Column To Column, Row By Row Worksheet name list

This is great, Thanks for the help on this. Do have another question. I have
a worksheet_selectionchange setup:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Value "" Then
Worksheets(ActiveCell.Value).Select
End If
End Sub

Now when I got to highlight the columns to delete the list of worksheets it
gives me an error:

Run Time Error: 13
Type Mismatch.

Is there any way to delete the data with out getting this error? I have
tried vba to ignore the error and continue with the action but I cannot seem
to get it to work.
"Toppers" wrote:

Kyer,

try this:

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer, iCol As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2
iCol = 1
For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(iCol).Value = ws.Name

iRow = iRow + 1
If iRow 30 Then
iRow = 2
iCol = iCol + 1
End If

Next

Range("A1").Select
End Sub

"Kryer" wrote:

I have a workbook that has close to 100 worksheets in it and have come up
with a little this code to list all the worksheet names on a single worksheet
starting at row 2. What I am trying to do is manipulate this code even
further that states to have it list the worksheets from row 2 down to row 30
in column 1, then move over to column 2 and do the same thing from row 2 to
30 and so on till all names have been listed.

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2

For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(1).Value = ws.Name

iRow = iRow + 1

Next

Range("A1").Select
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Column To Column, Row By Row Worksheet name list

It errors because the range is a column (multi-cell) rather than one cell

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count 1 Then Exit Sub 'Not single cell
If Target.Value "" Then
Worksheets(ActiveCell.Value).Select
End If
End Sub

"Kryer" wrote:

This is great, Thanks for the help on this. Do have another question. I have
a worksheet_selectionchange setup:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Value "" Then
Worksheets(ActiveCell.Value).Select
End If
End Sub

Now when I got to highlight the columns to delete the list of worksheets it
gives me an error:

Run Time Error: 13
Type Mismatch.

Is there any way to delete the data with out getting this error? I have
tried vba to ignore the error and continue with the action but I cannot seem
to get it to work.
"Toppers" wrote:

Kyer,

try this:

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer, iCol As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2
iCol = 1
For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(iCol).Value = ws.Name

iRow = iRow + 1
If iRow 30 Then
iRow = 2
iCol = iCol + 1
End If

Next

Range("A1").Select
End Sub

"Kryer" wrote:

I have a workbook that has close to 100 worksheets in it and have come up
with a little this code to list all the worksheet names on a single worksheet
starting at row 2. What I am trying to do is manipulate this code even
further that states to have it list the worksheets from row 2 down to row 30
in column 1, then move over to column 2 and do the same thing from row 2 to
30 and so on till all names have been listed.

Sub ShowNames_Click()
Dim wkbkToCount As Workbook
Dim ws As Worksheet
Dim iRow As Integer
Set wkbkToCount = ActiveWorkbook
iRow = 2

For Each ws In wkbkToCount.Worksheets
ActiveSheet.Rows(iRow).Cells(1).Value = ws.Name

iRow = iRow + 1

Next

Range("A1").Select
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
Excel worksheet first column - the row indicator column sfurney Excel Worksheet Functions 7 January 30th 09 08:57 PM
Look up and match Vendor name in one cell of worksheet from list ofmultiple Vendor names in column of other worksheet insitedge Excel Worksheet Functions 2 March 11th 08 11:36 PM
Based on a condition in one column, search for a year in another column, and display data from another column in the same row look [email protected] Excel Discussion (Misc queries) 1 December 27th 06 05:47 PM
how to copy contents of one column to another column in another worksheet yefei Excel Discussion (Misc queries) 3 February 25th 06 05:57 PM
Sorting a 2 column list with VBA using Worksheet change produces 1004 error Casey[_10_] Excel Programming 3 June 28th 04 04:38 PM


All times are GMT +1. The time now is 02:24 PM.

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"