+ Reply to Thread
Results 1 to 8 of 8

How to use if and loop functions

  1. #1
    Registered User
    Join Date
    03-13-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    21

    How to use if and loop functions

    Hi all, I have few questions, sorry I'm a Newbie to Macro.

    I attached a sample of the file I am working on.
    BOOK1.xlsx
    What I am trying to do is to build a macro the will do the following:
    --Go to sheet Input , then copy A2:D2
    --Go to sheet Calculation and paste it in the second line A2:D2
    If D2=12 then copy A4:D15
    If D2=11 then copy A4:D14
    If D2=10 then copy A4:D13
    and so on until D2=1 then copy A4:D4
    --Go to sheet Output and paste in the first empty line
    then loop again to take next line in the Input Sheet.
    Is that easy ?
    Last edited by gogz2005; 03-15-2014 at 01:14 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: How to use if and loop functions

    its easy not so hard but please wait for reply i m making code for you.

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: How to use if and loop functions

    Hi, gogz2005,

    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.

    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)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    03-13-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: How to use if and loop functions

    Quote Originally Posted by mahaveersomani View Post
    its easy not so hard but please wait for reply i m making code for you.
    Thank you very much. I appreciate you.

  5. #5
    Registered User
    Join Date
    03-13-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: How to use if and loop functions

    Quote Originally Posted by HaHoBe View Post
    Hi, gogz2005,

    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.

    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)

    Ciao,
    Holger
    I'm so sorry Holger I didn't know that, I edited it.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: How to use if and loop functions

    Hi, gogz2005,

    maybe use a code like this:
    Please Login or Register  to view this content.
    CIao,
    Holger

  7. #7
    Registered User
    Join Date
    03-13-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    21

    Re: How to use if and loop functions

    Quote Originally Posted by HaHoBe View Post
    Hi, gogz2005,

    maybe use a code like this:
    Please Login or Register  to view this content.
    CIao,
    Holger
    Wow Holger, thank you very much. It is working very well. I never though that you can fit that into 4 lines!
    I appreciate your time and help !

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2507 Win 11
    Posts
    24,923

    Re: How to use if and loop functions

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

    Did you know that to say thank you, click on the star at the bottom of the post for the person who helped you? (Add Reputation)
    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

+ 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 with Excel functions possible?
    By ras100 in forum Excel General
    Replies: 1
    Last Post: 02-25-2012, 05:55 PM
  2. Replies: 1
    Last Post: 11-02-2011, 02:12 PM
  3. Alternate loop functions?
    By 13chompie13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2011, 03:01 AM
  4. Replies: 0
    Last Post: 07-12-2010, 10:24 AM
  5. Use for loop with functions
    By Rodas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-03-2009, 02:29 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