+ Reply to Thread
Results 1 to 14 of 14

Macro to Loop Function throughout selected cells

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro to Loop Function throughout selected cells

    Hi there,

    This is my first time posting up on this site, I am very new to Macros and appreciate it if anyone could help me out with my situation.

    Objective - Repeat my function for the following other rows

    Function in hand:

    Please Login or Register  to view this content.
    Attached is an example of what it is I'm trying to do, as of now the function only works with the first row and once again I would like it to work for the rest. I need to repeat this for my original excel file which has 1000 rows.

    Help.xlsm

    Anyone and everyones help is greatly appreciated!

    Alvinz
    Last edited by arlu1201; 09-20-2012 at 02:13 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to Loop Function throughout selected cells

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to Loop Function throughout selected cells

    Thanks Arlette,

    Will take note for future reference. Do you have any idea on my situation?

    Thanks,

    Alvin
    Last edited by Cutter; 09-20-2012 at 11:30 AM. Reason: Removed whole post quote

  4. #4
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    Hey Alvin,

    Try using the intersect function, something like this is what you are after:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    It may be better though Alvin to tell us what you actually want to achieve. Excel automatically selects the next cell on the line below that should be filled in once the user hits the enter key, which it seems like you are trying to do in your code too!

  6. #6
    Registered User
    Join Date
    09-19-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to Loop Function throughout selected cells

    Hi Blobbles,
    I'm trying to remove errors made from users.
    Without my current code, if changes where made to the drop down list in column B, no changes would be made to the drop down list in column A.
    With the code, I am trying to ensure that if changes were made to column B, it will automatically take you two the corresponding drop down list in column A.

    I would like this to work for all the following rows.
    I hope I made my situation more clear, I'm struggling to explain as it is. haha.
    I will try the code you have provided.

    Thank you!
    Last edited by Cutter; 09-20-2012 at 11:31 AM. Reason: Removed whole post quote

  7. #7
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    Ahhh, OK, good.

    In this scenario I would normally do something like the attached, check it out!

    ListChecker.xls

    The problem with your approach (well, you haven't specified yet!) is that the user still doesn't HAVE to put anything into the 1st column. Giving them a big "Error!" message or something similar makes it a bit more obvious!

  8. #8
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    Oh yeah - SendKeys can sometimes get you into trouble, try not to use them...
    And check out the way code is indented in the sheet I uploaded. It makes it a lot more readable right?

  9. #9
    Registered User
    Join Date
    09-19-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to Loop Function throughout selected cells

    Hey Blobbles,
    Thanks for all that. I understand what you're saying but unfortunately my manager is after something else.
    If you have a look at my attached sheet, I have two dropdown list.
    Users are not required to enter anything, only select from the lists provided.
    For example:
    1. Users will select "Meat" from the dropdown menu in Col B.
    2. After that they will select the type of meat "Lamb" from dropdown menu in Col A.
    3. If someone was to go back to the first row and select "Veg" in Col B, it will still appear as "Lamb" in Col A.
    4. Hence the reason for the current code.

    If you know how to apply that code to the rest of the required rows it would be most helpful.
    I agree it is complicated and can be troublesome but I have to try to get it the way they want it.

    Thanks. =)
    Last edited by Cutter; 09-20-2012 at 11:31 AM. Reason: Removed whole post quote

  10. #10
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    Check out the sheet attached, should be what you are after :-)

    Sorry, I didn't see your uploaded sheet before!

    Help.xlsm

  11. #11
    Registered User
    Join Date
    09-19-2012
    Location
    Brisbane
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Macro to Loop Function throughout selected cells

    Hey Blobbes,

    Is there any reason why I can't download or see the attached file? :S
    Thanks!
    Last edited by Cutter; 09-20-2012 at 11:32 AM. Reason: Removed whole post quote

  12. #12
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    Hmmm, that's weird, try again!

    Help.xlsm

  13. #13
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    That one didn't work either... wonder if there is something wrong with the uploader and/or database?? Hey site admins! Somethings up!

    Help solved.xlsm

  14. #14
    Registered User
    Join Date
    09-20-2012
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Macro to Loop Function throughout selected cells

    PM me your email address Alvin, will send it to you :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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