+ Reply to Thread
Results 1 to 4 of 4

Excel VBA Looping

  1. #1
    Registered User
    Join Date
    03-13-2015
    Location
    london
    MS-Off Ver
    excel 2013
    Posts
    19

    Excel VBA Looping

    Morning Guys

    I have an excel worksheet with around 200 sheets. One of the sheet (NAMES) has names and their email address. What I am looking to do is write a VBA to, for example, look for a name on sheet1 A:1 Vlookup for that name in NAME sheet and bring back email address on each worksheet in cell XFD:1.

    The code I am trying is:

    For Each ws In ActiveWorkbook.Worksheets
    ******* If ws.Name <> "NAMES" Then
    *********** Range("XFD1").Select
    *********** ActiveCell.Formula = "=VLOOKUP(R[2]C[-16383],NAMES!C[-16383]:C[-16380],4,FALSE)"
    *********** Next ws


    It works on one sheet only, not looping. What am I doing wrong. Please advise.

    Many thanks in advance.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Excel VBA Looping

    Please use Code Tags in your code excerpts. Try:

    Please Login or Register  to view this content.

    Regards, TMS



    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
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-13-2015
    Location
    london
    MS-Off Ver
    excel 2013
    Posts
    19

    Re: Excel VBA Looping

    Many thanks TMS, it works like a magic

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Excel VBA Looping

    You're welcome. Thanks for the rep.

    Don't forget the Code Tags




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Looping excel function using VBA
    By drrazor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-29-2014, 10:52 AM
  2. Looping through Excel files
    By PandaSlo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2013, 06:40 AM
  3. [SOLVED] Looping Excel Formulas
    By boiledbeans in forum Excel General
    Replies: 12
    Last Post: 04-25-2012, 02:15 PM
  4. Looping through tabe in excel
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2011, 09:18 AM
  5. Excel Looping Problem
    By ThrowerMatt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2007, 04:34 PM
  6. Excel:Looping
    By Murph in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2006, 05:45 PM
  7. looping in vba for excel
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2005, 11: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