+ Reply to Thread
Results 1 to 6 of 6

looking for help with For/Each VBA code

  1. #1
    Forum Contributor
    Join Date
    09-12-2013
    Location
    chicago, illinois
    MS-Off Ver
    Excel 2010
    Posts
    109

    looking for help with For/Each VBA code

    hi all, im sure this is simple but for SOME reason i have been having trouble grasping the concept of how to properly loop something or execute a for/each statement so if anyone knows a nice website with a tutorial on this that is easy to understand i would love that as well. anyways, what i am trying to do is simple i think. i have the code for an input box to come up for the user to type in a number. the number is assigned an integer variable, sheet_count, this is the number of new sheets i will create in the workbook. then i need code for what i think is an array??

    something like: for each worksheet in sheet_count, then other code in here

    i just can't grasp it, sorry if this seems really stupid!! =)

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: looking for help with For/Each VBA code

    You wouldn't use For Each for that, you would use a standard For like this.

    For example.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    09-12-2013
    Location
    chicago, illinois
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: looking for help with For/Each VBA code

    AHH!! thank you so much Norie, i really have to nail this stuff down into my brain.

  4. #4
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: looking for help with For/Each VBA code

    You actually don't need a loop for that at all. You can just use the Count argument of Sheets.Add

    Please Login or Register  to view this content.
    Regards,
    Rudi

  5. #5
    Forum Contributor
    Join Date
    09-12-2013
    Location
    chicago, illinois
    MS-Off Ver
    Excel 2010
    Posts
    109

    Re: looking for help with For/Each VBA code

    oh excellent!! thanks rudis, as it works out, this works perfect for the one thing, and Norie's code solves another issue i would have had a question on anyways =)

    many thanks

  6. #6
    Valued Forum Contributor
    Join Date
    07-04-2012
    Location
    Cape Town, RSA
    MS-Off Ver
    Office 365 ProPlus
    Posts
    1,050

    Re: looking for help with For/Each VBA code

    LOL.... The value of 1 question ... You get double the return.
    That's a great investment!

+ 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. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  2. [SOLVED] Excel Macro Visual Basic code not looking at all sheets with second section of code.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2014, 08:26 AM
  3. Replies: 2
    Last Post: 03-09-2013, 04:30 AM
  4. Adding Text to another cell VB code (Help Tweeking code) (Excel 2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 11:37 AM
  5. Replies: 0
    Last Post: 10-06-2006, 09:05 AM

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