PC Review


Reply
Thread Tools Rate Thread

column to row macro

 
 
Steve
Guest
Posts: n/a
 
      1st Oct 2009
morning all.
I have a text document that I've imported to Excel. It's on one row, across
approximately 1000 columns. I.e., out to AXD.

I need to move the cell contents for each into a single column-- A.

I'm thinking something along the line of-

dim i as integer

while activecell.value<>""

select.offset(0,i).cut

select.offset(1,-i).paste

loop

Your helps are appreciated.
Thank you.


 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      1st Oct 2009
No loop is needed:

Sub Steve()
Dim n As Long
n = Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(1, 1), Cells(1, n)).Copy
Range("A2").PasteSpecial Paste:=xlPasteAll, Transpose:=True
End Sub

--
Gary''s Student - gsnu200906


"Steve" wrote:

> morning all.
> I have a text document that I've imported to Excel. It's on one row, across
> approximately 1000 columns. I.e., out to AXD.
>
> I need to move the cell contents for each into a single column-- A.
>
> I'm thinking something along the line of-
>
> dim i as integer
>
> while activecell.value<>""
>
> select.offset(0,i).cut
>
> select.offset(1,-i).paste
>
> loop
>
> Your helps are appreciated.
> Thank you.
>
>

 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      1st Oct 2009
k-ching!!!!! Wow.... all in one action too.

Thank you!!!!!!!!!
I'll have to read more on transpose.... that's a good one to know.
Have a great day.

"Gary''s Student" wrote:

> No loop is needed:
>
> Sub Steve()
> Dim n As Long
> n = Cells(1, Columns.Count).End(xlToLeft).Column
> Range(Cells(1, 1), Cells(1, n)).Copy
> Range("A2").PasteSpecial Paste:=xlPasteAll, Transpose:=True
> End Sub
>
> --
> Gary''s Student - gsnu200906
>
>
> "Steve" wrote:
>
> > morning all.
> > I have a text document that I've imported to Excel. It's on one row, across
> > approximately 1000 columns. I.e., out to AXD.
> >
> > I need to move the cell contents for each into a single column-- A.
> >
> > I'm thinking something along the line of-
> >
> > dim i as integer
> >
> > while activecell.value<>""
> >
> > select.offset(0,i).cut
> >
> > select.offset(1,-i).paste
> >
> > loop
> >
> > Your helps are appreciated.
> > Thank you.
> >
> >

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      1st Oct 2009
Thanks for the feeedback.
--
Gary''s Student - gsnu200906


"Steve" wrote:

> k-ching!!!!! Wow.... all in one action too.
>
> Thank you!!!!!!!!!
> I'll have to read more on transpose.... that's a good one to know.
> Have a great day.
>
> "Gary''s Student" wrote:
>
> > No loop is needed:
> >
> > Sub Steve()
> > Dim n As Long
> > n = Cells(1, Columns.Count).End(xlToLeft).Column
> > Range(Cells(1, 1), Cells(1, n)).Copy
> > Range("A2").PasteSpecial Paste:=xlPasteAll, Transpose:=True
> > End Sub
> >
> > --
> > Gary''s Student - gsnu200906
> >
> >
> > "Steve" wrote:
> >
> > > morning all.
> > > I have a text document that I've imported to Excel. It's on one row, across
> > > approximately 1000 columns. I.e., out to AXD.
> > >
> > > I need to move the cell contents for each into a single column-- A.
> > >
> > > I'm thinking something along the line of-
> > >
> > > dim i as integer
> > >
> > > while activecell.value<>""
> > >
> > > select.offset(0,i).cut
> > >
> > > select.offset(1,-i).paste
> > >
> > > loop
> > >
> > > Your helps are appreciated.
> > > Thank you.
> > >
> > >

 
Reply With Quote
 
mark_the_yeti
Guest
Posts: n/a
 
      2nd Oct 2009
You don't even need to write code if you're only doing it once or twice -
just select the cells, right-click-cut, right-click-paste special, select
transpose.

"Steve" wrote:

> k-ching!!!!! Wow.... all in one action too.
>
> Thank you!!!!!!!!!
> I'll have to read more on transpose.... that's a good one to know.
> Have a great day.
>
> "Gary''s Student" wrote:
>
> > No loop is needed:
> >
> > Sub Steve()
> > Dim n As Long
> > n = Cells(1, Columns.Count).End(xlToLeft).Column
> > Range(Cells(1, 1), Cells(1, n)).Copy
> > Range("A2").PasteSpecial Paste:=xlPasteAll, Transpose:=True
> > End Sub
> >
> > --
> > Gary''s Student - gsnu200906
> >
> >
> > "Steve" wrote:
> >
> > > morning all.
> > > I have a text document that I've imported to Excel. It's on one row, across
> > > approximately 1000 columns. I.e., out to AXD.
> > >
> > > I need to move the cell contents for each into a single column-- A.
> > >
> > > I'm thinking something along the line of-
> > >
> > > dim i as integer
> > >
> > > while activecell.value<>""
> > >
> > > select.offset(0,i).cut
> > >
> > > select.offset(1,-i).paste
> > >
> > > loop
> > >
> > > Your helps are appreciated.
> > > Thank you.
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro that uses column headings as column sort 'buttons' Rob Benz Microsoft Excel Programming 4 22nd Jan 2009 08:43 PM
A formula or macro that will place the date in an adjacent column Bany time something is typed in column A Mike C Microsoft Excel Programming 4 27th Feb 2008 01:57 AM
Macro - Insert&Label Column, if the labeled column doesn't exist Jeff Microsoft Excel Programming 1 15th Dec 2004 09:33 PM
Need Macro to Find Column Heading -- if none, then insert new column Jeff Microsoft Excel Programming 0 15th Dec 2004 07:08 AM
macro to transpose cells in Column B based on unique values in Column A Aaron J. Microsoft Excel Programming 3 8th Oct 2004 02:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:43 AM.