Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default moving rows into columns

I have a spreadsheet where column a has the customer name, under column b I
have 8 cells with information that I move to columns.
Column a: Name
Column b: item 1
item 2
:
Item 8
and I want to display it as:
Column a: name, Column b: item1, column c: item 2...
Is there a way to do it without having to do it manually? Your assistance
is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default moving rows into columns

The following code will do it.

Sub AAA()
Dim StartCell As Range
Dim N As Long
Dim DestCell As Range

'<< CHANGE StartCell to the first cell of data
'<< CHANGE DestCell to the first cell of the new data
Set StartCell = Worksheets("Sheet1").Range("A1")
Set DestCell = Worksheets("Sheet2").Range("A1")

Do Until False
DestCell = StartCell.Value
For N = 1 To 8
DestCell(1, N + 1) = StartCell(N, 2)
Next N
Set StartCell = StartCell(9, 1)
Set DestCell = DestCell(2, 1)
If StartCell(1, 2) = vbNullString Then
Exit Do
End If
Loop
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Fri, 28 Aug 2009 09:33:01 -0700, Jerry
wrote:

I have a spreadsheet where column a has the customer name, under column b I
have 8 cells with information that I move to columns.
Column a: Name
Column b: item 1
item 2
:
Item 8
and I want to display it as:
Column a: name, Column b: item1, column c: item 2...
Is there a way to do it without having to do it manually? Your assistance
is greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default moving rows into columns

Chip:
It help a lot, now the question is how can I pick instead of column b pick
column d?

"Chip Pearson" wrote:

The following code will do it.

Sub AAA()
Dim StartCell As Range
Dim N As Long
Dim DestCell As Range

'<< CHANGE StartCell to the first cell of data
'<< CHANGE DestCell to the first cell of the new data
Set StartCell = Worksheets("Sheet1").Range("A1")
Set DestCell = Worksheets("Sheet2").Range("A1")

Do Until False
DestCell = StartCell.Value
For N = 1 To 8
DestCell(1, N + 1) = StartCell(N, 2)
Next N
Set StartCell = StartCell(9, 1)
Set DestCell = DestCell(2, 1)
If StartCell(1, 2) = vbNullString Then
Exit Do
End If
Loop
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Fri, 28 Aug 2009 09:33:01 -0700, Jerry
wrote:

I have a spreadsheet where column a has the customer name, under column b I
have 8 cells with information that I move to columns.
Column a: Name
Column b: item 1
item 2
:
Item 8
and I want to display it as:
Column a: name, Column b: item1, column c: item 2...
Is there a way to do it without having to do it manually? Your assistance
is greatly appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default moving rows into columns

Chip:
Never mind, I just found the cell. Thanks a lot

"Chip Pearson" wrote:

The following code will do it.

Sub AAA()
Dim StartCell As Range
Dim N As Long
Dim DestCell As Range

'<< CHANGE StartCell to the first cell of data
'<< CHANGE DestCell to the first cell of the new data
Set StartCell = Worksheets("Sheet1").Range("A1")
Set DestCell = Worksheets("Sheet2").Range("A1")

Do Until False
DestCell = StartCell.Value
For N = 1 To 8
DestCell(1, N + 1) = StartCell(N, 2)
Next N
Set StartCell = StartCell(9, 1)
Set DestCell = DestCell(2, 1)
If StartCell(1, 2) = vbNullString Then
Exit Do
End If
Loop
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Fri, 28 Aug 2009 09:33:01 -0700, Jerry
wrote:

I have a spreadsheet where column a has the customer name, under column b I
have 8 cells with information that I move to columns.
Column a: Name
Column b: item 1
item 2
:
Item 8
and I want to display it as:
Column a: name, Column b: item1, column c: item 2...
Is there a way to do it without having to do it manually? Your assistance
is greatly appreciated.


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
Moving info from rows to columns Mary Lou[_2_] Excel Worksheet Functions 2 October 28th 09 01:34 AM
Moving Data from Rows to Columns Josue Preciado Excel Programming 1 October 24th 06 06:38 PM
Another question moving rows to columns fivestringfreak Excel Programming 2 December 9th 05 07:43 AM
Moving rows to columns Jan Verten Excel Discussion (Misc queries) 5 September 2nd 05 04:08 PM
Moving columns into rows jim314 Excel Discussion (Misc queries) 1 March 30th 05 10:24 PM


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