Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cuting and pasting problem 1

Status
Not open for further replies.

JVZ

Programmer
Sep 3, 2002
205
CA
I was wondering if someone can help right a macro for this problem I'm having (sorry I kindof new to the VBA world)..

I have a excel worksheet that kind on looks like:

somevalue1 someValue2 SomeValue3 someValue4

Using a macro is there a way to change that to look like this:

someValue1
someValue2
someValue3
someValue4

Here is what I have so far: (I think my logic for this is wrong)
Code:
Dim i As Integer

For i = 1 To 61
    ActiveCell.Offset(0, 1).Select
    Selection.Cut
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste
    Next i
End Sub
 
Weeeeeelll - you don't really need to use code
Just select your values
CTRL+C (copy)
select a blank cell
Edit>Pastespecial
Choose "Values" AND tick "Transpose"
et voila

If you want the code to do this, just record yourself (the little circle on the VBA toolbar) doing it Rgds
Geoff

Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur
 
But if you're trying to do something more complex and are just playing around, here's how you'd modify it to work programmatically:

Dim i As Integer
For i = 1 To 61
ActiveCell.Offset(0, i).cut
ActiveCell.Offset(i, 0).paste
Next i


Rob
[flowerface]
 
Thanks Xlbo, I never knew you could do that, here's a star!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top