Results 1 to 4 of 4

How to repeat a macro x number of times based on a value in a cell

Threaded View

  1. #1
    Registered User
    Join Date
    09-05-2011
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    2

    How to repeat a macro x number of times based on a value in a cell

    My apologies if I do not have this formatted correctly, this is my first time posting.

    I have a spreadsheet (attached) that runs a macro to copy a column of data from one page to the next. The criteria used to determine which column to copy is determined by the value in cell C147 (which be updated at a later time). The number of times to repeat the macro is determined by a countif command in cell C124, which counts the number of times the value in cell C147 is in row 122.

    Here is the macro that I want to repeat:


    Sub Move()
    '
    ' Move Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+M
    '
       Sheets("Data").Select
        Range("A122").Select
        Cells.Find(What:=ActiveSheet.Range("C147"), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
            xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False).Activate
        Range(Selection, Selection.End(xlUp)).Select
        Selection.Copy
        Sheets("Sort").Select
        Range("A3").Select
        Selection.End(xlToRight).Select
        ActiveCell.Offset(-1, 1).Select
        ActiveSheet.Paste
        Range("D3").Select
        Sheets("Data").Select
        Selection.End(xlDown).Select
        Selection.End(xlUp).Select
        Selection.End(xlDown).Select
        Application.CutCopyMode = False
        Selection.Cut
        ActiveCell.Offset(1, 0).Select
        ActiveSheet.Paste
        ActiveCell.Offset(-1, 1).Select
    End Sub

    Any help would be appreciated.

    Thanks.
    Attached Files Attached Files
    Last edited by gypsyhotelier; 09-19-2011 at 05:15 PM. Reason: Solved! Thank You MarvinP!

Thread Information

Users Browsing this Thread

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

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