Results 1 to 7 of 7

Incorporate Loop Function In Recorded Macro

Threaded View

  1. #1
    Registered User
    Join Date
    06-02-2014
    Location
    Victoria, Australia
    MS-Off Ver
    Office 2007
    Posts
    6

    Incorporate Loop Function In Recorded Macro

    Hi,

    I have a CSV file which has data in the incorrect columns when the report has been created as per attachment.

    I have recorded the macro below which I will need to select a cell in column N before activating the macro, instead of activating the macro x amount of times until I've gone through the whole workbook, I would like to be able to press the macro once and the whole sheet has been done then go to cell A1 if possible.

    Sub AlignData()
    '
    ' AlignData Macro
    '
    
    '
        Range("N2").Select
        Selection.End(xlDown).Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Selection.Find(What:="CONT_ADV", After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        ActiveCell.Offset(0, -2).Range("A1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        ActiveCell.Range("A1:I1").Select
        Selection.Cut
        Selection.End(xlToLeft).Select
        ActiveCell.Offset(0, 6).Range("A1").Select
        ActiveSheet.Paste
        Selection.End(xlToRight).Select
        ActiveCell.Offset(0, 1).Range("A1").Select
    End Sub
    Thank you very much for looking into this, it is greatly appreciated.
    Regards,
    Attached Files Attached Files
    Last edited by tarktran; 12-27-2014 at 11:40 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Reduce code recorded from a macro in excel vba using a loop
    By VBA-Excel_Newbie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-24-2014, 05:00 AM
  2. [SOLVED] Recorded Pivot Table Macro Doesn't Do What I Recorded!
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 11:01 AM
  3. Make recorded macro loop
    By cowannbell in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 01-11-2013, 09:53 AM
  4. How to create a loop for recorded macro?
    By Partisano in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-30-2012, 12:03 PM
  5. [SOLVED] Incorporate (xlCellTypeVisible) into For..Next loop
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2012, 12:55 PM

Tags for this Thread

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