Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel worksheet first column - the row indicator column | Excel Worksheet Functions | |||
Look up and match Vendor name in one cell of worksheet from list ofmultiple Vendor names in column of other worksheet | Excel Worksheet Functions | |||
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 | Excel Discussion (Misc queries) | |||
how to copy contents of one column to another column in another worksheet | Excel Discussion (Misc queries) | |||
Sorting a 2 column list with VBA using Worksheet change produces 1004 error | Excel Programming |