Using a Loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ranjcar
    New Member
    • Dec 2009
    • 2

    Using a Loop

    I have recorded a Macro on Excel 2007 to sort a column of 912 counts into its constituents. I am a VBA beginner and have tried to set up a loop. I have not succeeded over the last few days. Please could someone help?

    Description:
    The column exists as follows and contains 776 counts of three headers Name, Univ. Name, eMail :
    Harry, Garry
    My University
    Harrysg1@myuniv ersity.edu
    Next,Garry
    NextMy University
    NextHarrysg1@my university.edu

    I am trying to sort this one continuous column into three rows with the headers mentioned above ie. Name, Univ. Name, eMail

    How can I modify my Macro to loop so that it covers all the 912 cells in the column and spit out the results in rows?

    Sheets("Sheet2" ).Select
    Range("A1:A3"). Select
    Selection.Copy
    Sheets("Sheet3" ).Select
    Selection.Paste Special Paste:=xlPasteA ll, Operation:=xlNo ne, SkipBlanks:= _
    False, Transpose:=True
    Range("A2").Sel ect
    ActiveCell.Offs et(2, 0).Select

    End Sub

    Thanks
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    dear,

    I think the best way is to use an array.
    I have writen an macro (see attachment)
    Hopefully is this a solution for your problem.
    if not, please let me know.

    br,
    Attached Files

    Comment

    • ranjcar
      New Member
      • Dec 2009
      • 2

      #3
      Hi ggeu,

      Thank you. That Macro worked perfectly. I appreciate your taking the time to help me.

      Any recommendations on a book that I can use to get an introduction into VBA programming, that has been written for a person without a programming background?

      Thanks again,


      R

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        dear,

        this are good free ebooks:



        .....

        just look on the web for "free vba ebook" and you will find several websites.

        br,

        Comment

        Working...