+ Reply to Thread
Results 1 to 8 of 8

Help with Macro Loop

  1. #1
    Registered User
    Join Date
    07-17-2018
    Location
    LA, California
    MS-Off Ver
    2010
    Posts
    4

    Thumbs up Help with Macro Loop

    Hello,

    I am attempting to write a macro loop that essentially adds 5 to each number in the previous iteration for a series of operations. They are as follows:

    Please Login or Register  to view this content.
    So the next iteration would be:
    Please Login or Register  to view this content.
    and so on.....
    Is there just a simple way to loop this??? I have to do this set of operations many times and going in and changing each number defeats the purpose of the macro. Any help greatly appreciated. Thank you!!!
    Attached Files Attached Files
    Last edited by mjuarez1; 07-17-2018 at 05:40 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Help with Macro Loop

    Welcome

    Unfortunately nobody can help you until you comply with rule 3.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Help with Macro Loop

    I can't figure out your pattern. Can you post like the math between each cut/paste, please?

    There's a simple solution including a For loop. Moreover, you selecting and activating is unnecessary.

    This:
    Please Login or Register  to view this content.
    Can be this:

    Please Login or Register  to view this content.
    And this:

    Please Login or Register  to view this content.
    Can be this:

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Registered User
    Join Date
    07-17-2018
    Location
    LA, California
    MS-Off Ver
    2010
    Posts
    4

    Re: Help with Macro Loop

    Thanks for replying!

    The code I have is just the macro I recorded using the keyboard and mouse (hence all the unnecessary stuff).

    As far as the math goes the pattern is a tad confusing but I should have explained that basically what I am trying to do is take a data sheet with thousands of rows and 5 columns (the first row starts at 8 because there is header stuff above) and reorganize it into one with 8 columns, but they must be in the same order. So what I did was record myself doing it by hand.

    Hope I'm being clear, really appreciate the help.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,019

    Re: Help with Macro Loop

    reorganize it into one with 8 columns,
    Explain the process in simple English. Be sure to explain the criteria in each case as if this was to be done manually. Once we understand the desired process we can give you a simplified macro to do this.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Help with Macro Loop

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 07-17-2018 at 04:35 PM.

  7. #7
    Registered User
    Join Date
    07-17-2018
    Location
    LA, California
    MS-Off Ver
    2010
    Posts
    4

    Re: Help with Macro Loop

    Sorry for the confusion. To better clarify, I have attached a file here and to the original post. On Sheet1 is an example of what I would like to alter using the macro. Because the information is sensitive and for simplicity's sake, I have deleted a significant amount of rows, though in the actual file there are thousands. The asterisks are just placeholders and do not need to be altered in any way. On sheet2 is the result I am looking for. Notice how the order of the data is preserved while the number of columns has gone from 5 to 8. I did this all by hand.

    Hope that clears things up, thank you all for your help.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-17-2018
    Location
    LA, California
    MS-Off Ver
    2010
    Posts
    4

    Re: Help with Macro Loop

    mehmetcik I altered your code a bit and got it to work!!! Thank you x10000000000.

    Please Login or Register  to view this content.

+ 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. Loop Macro with Images getting distorted during loop
    By luxy007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2017, 01:57 PM
  2. Replies: 3
    Last Post: 01-07-2015, 12:19 PM
  3. [SOLVED] Have a loop macro loop for all visible worksheets
    By Graeme-Black in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-22-2014, 11:01 AM
  4. Novice with VBA and macro writing needing help to loop a macro unti no data
    By jrongone in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-25-2013, 12:19 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Macro to delete rows with a Zero value. Macro seems to be in continual loop
    By jnorri in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-07-2012, 03:20 PM
  7. Macro Loop Broken. Detects Max but doesn't continue loop
    By herchenbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2011, 12:17 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