Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Use a List to Generate Worksheets

I have a list of data beginning in cell A1 of Sheet #2 and may be of any
length in column A. I'd like to take that list, and using Sheet #3 as a
template, create Sheet #4 with the data in A1, A2, A3 etc in Sheet #2
transposed into cells B1, C1, D1 etc on sheet #4.

Thanks in advance for the help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Use a List to Generate Worksheets

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/17/2007
'

'
Sheets("Sheet3").Select
Sheets("Sheet3").Copy After:=Sheets(3)
ActiveSheet.Name = "Sheet4"

LastRow = Sheets("Sheet2"). _
Cells(Rows.Count, "A").End(xlUp).Row
If LastRow 255 Then LastRow = 255
Sheets("Sheet2").Activate
Set copyrange = Range(Cells(1, "A"), Cells(LastRow, "A"))

copyrange.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
Cells(1, "B").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True
End Sub


"Mr. Matt" wrote:

I have a list of data beginning in cell A1 of Sheet #2 and may be of any
length in column A. I'd like to take that list, and using Sheet #3 as a
template, create Sheet #4 with the data in A1, A2, A3 etc in Sheet #2
transposed into cells B1, C1, D1 etc on sheet #4.

Thanks in advance for the help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Use a List to Generate Worksheets

Hi Mr. Matt

The code below would be one way of doing it

Option Explicit
Dim LstRow As Integer
Dim WkSh As Worksheet
Dim MyRng As Range

Private Sub CommandButton1_Click()

Sheets(2).Activate

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LstRow)

Sheets("Sheet3").Copy After:=Sheets(3)

ActiveSheet.Name = "Sheet4"

MyRng.Copy

[B1].PasteSpecial Transpose:=True

End Sub

Hope this helps

S

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Use a List to Generate Worksheets

when you are usingg 2003 there is a limit of the number of columns to 256.
when you transpose 65535 row into columns you get an error. This problem was
noted on the original request when Mr. Matt said the data can be "any Length".

"Incidental" wrote:

Hi Mr. Matt

The code below would be one way of doing it

Option Explicit
Dim LstRow As Integer
Dim WkSh As Worksheet
Dim MyRng As Range

Private Sub CommandButton1_Click()

Sheets(2).Activate

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LstRow)

Sheets("Sheet3").Copy After:=Sheets(3)

ActiveSheet.Name = "Sheet4"

MyRng.Copy

[B1].PasteSpecial Transpose:=True

End Sub

Hope this helps

S


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Use a List to Generate Worksheets

I just thought of a good improvement to make the code compatabble witth 2003
and 2007

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/17/2007
'

'
Sheets("Sheet3").Select
Sheets("Sheet3").Copy After:=Sheets(3)
ActiveSheet.Name = "Sheet4"

LastRow = Sheets("Sheet2"). _
Cells(Rows.Count, "A").End(xlUp).Row
If LastRow (Rows.Count - 1) Then LastRow = Rows.Count - 1
Sheets("Sheet2").Activate
Set copyrange = Range(Cells(1, "A"), Cells(LastRow, "A"))

copyrange.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet4").Select
[B1].PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks :=False, Transpose:=True
End Sub



"Joel" wrote:

when you are usingg 2003 there is a limit of the number of columns to 256.
when you transpose 65535 row into columns you get an error. This problem was
noted on the original request when Mr. Matt said the data can be "any Length".

"Incidental" wrote:

Hi Mr. Matt

The code below would be one way of doing it

Option Explicit
Dim LstRow As Integer
Dim WkSh As Worksheet
Dim MyRng As Range

Private Sub CommandButton1_Click()

Sheets(2).Activate

LstRow = [A65535].End(xlUp).Row

Set MyRng = Range("A1:A" & LstRow)

Sheets("Sheet3").Copy After:=Sheets(3)

ActiveSheet.Name = "Sheet4"

MyRng.Copy

[B1].PasteSpecial Transpose:=True

End Sub

Hope this helps

S


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
How generate new list in another worksheet from existing list? NSF Excel Worksheet Functions 0 September 24th 08 01:08 PM
how do I generate lists in worksheets based on a master list works Furlong Excel Worksheet Functions 10 July 15th 07 09:36 AM
How do I generate a list of the tabs/worksheets from a workbook? tjennings Excel Worksheet Functions 7 May 23rd 07 09:51 PM
How can I generate a list of the worksheets by name georgia-miner Excel Discussion (Misc queries) 2 April 27th 07 08:10 PM
Compare worksheets and generate list of missing data? Minuette Excel Worksheet Functions 4 November 3rd 05 01:37 PM


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