+ Reply to Thread
Results 1 to 4 of 4

Repeat macro until empty cell is reached

Hybrid View

  1. #1
    Registered User
    Join Date
    04-16-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    9

    Repeat macro until empty cell is reached

    Hi I have the following Macro to transpose data from a column into succesive rows. I need it to repeat, until it has processed all data in column A / until it reaches an empty cell in A.

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Range("A1:A5").Select
    Selection.Copy
    Range("B1:F1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A6:A10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B2:F2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    End Sub
    Sub Macro2()
    '

    ' Macro2 Macro
    '

    '
    Range("A1:A5").Select
    Selection.Copy

    Range("C1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A6:A10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("C6").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A11:A15").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("C11").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True


    End Sub
    Sub Transpose()
    '
    ' Transpose Macro
    '

    '
    Range("A1:A5").Select
    Selection.Copy
    Range("B1").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A6:A10").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B2:F2").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A11:A15").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B3").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    Range("A16:A20").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B4").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=True
    End Sub

    Any help would be great!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Repeat macro until empty cell is reached

    I am not sure on some of the things you said. Maybe this:

    Sub RunMe()
    Dim ws As Worksheet:    Set ws = Sheets("Sheet1") 'you may need to change this
    Dim lcell As Long
    
    For lcell = 1 To ws.Range("A" & Rows.Count).End(xlUp).Row Step 5
        If IsEmpty(ws.Range("A" & lcell)) Then Exit Sub
        ws.Range("A" & lcell).Resize(5, 1).Copy
        ws.Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll, Transpose:=True
    Next lcell
    
    Application.CutCopyMode = False
    
    End Sub

  3. #3
    Registered User
    Join Date
    04-16-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Repeat macro until empty cell is reached

    [QUOTE=stnkynts;3686458]I am not sure on some of the things you said. Maybe this:

    Apologies, I got this from recording a Macro. I am highlighting 5 cells down a column then using paste special to copy them to a row.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Repeat macro until empty cell is reached

    Did the macro I supplied accomplish what you wanted?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Repeat macro until last empty cell
    By shaikhstonevilla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 01:22 AM
  2. [SOLVED] Repeat macro until reach empty cell
    By johnson1421 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2012, 03:51 PM
  3. Replies: 3
    Last Post: 04-12-2012, 01:57 PM
  4. [SOLVED] repeat macro until empty space in next column
    By Sabba Efie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-15-2006, 04:10 PM
  5. Repeat Macro until Empty Cell Reached
    By clpncsg in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-30-2005, 10:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1