+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : If Then Else and/or Select Case Coding Assistance

  1. #1
    Registered User
    Join Date
    06-29-2012
    Location
    SF
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question If Then Else and/or Select Case Coding Assistance

    So I am trying to get the following If then else statement to work. I believe I am having the most difficulty in getting the embedded loop to loop (the "else" part of the macro)

    I believe the code shows what I am trying to do pretty clearly, which is if a cell in sheet1 equals a cell in sheet 2, make the original sheet 1 cell equal to a cell in sheet 2. the Part I am having trouble with is that if the cell doesn't equal the cell in sheet2, I want it to continue going down the list until it hits the cell for which it is equivalent.

    Please Login or Register  to view this content.
    Here's my Attempt at a Select Case way of doing this (also doesn't work but looks much cleaner)
    Please Login or Register  to view this content.
    Last edited by MrSir; 07-03-2012 at 02:49 PM. Reason: Additional Info

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Then Else and/or Select Case Coding Assistance

    Your code may not even be doing what you think. It seems to read like:

    Please Login or Register  to view this content.
    You can see how it appears to just spin. I would think that if Cat = Cat, then you would want to update a cell NEXT to Cat with a value NEXT to Cat.

    If this is the case, then I would suggest you use the FIND method to simply attempt to JUMP straight to the cell with the searched value. If the FIND works, you adjust the value of the cell to the right. If not, it's not there, so you move on to the next value.

    Please Login or Register  to view this content.

    Obviously I may have the sheets backwards, so you can update which sheet is "search values" and which sheet should be updated as the Master.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If Then Else and/or Select Case Coding Assistance

    Thanks for the feedback. If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

  4. #4
    Registered User
    Join Date
    06-29-2012
    Location
    SF
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: If Then Else and/or Select Case Coding Assistance

    Was waiting to play around with the code at work but everything works great, thank you so much for the hlp! The find function was definitely the way to go, got a bit too caught up in other functions and overlooked it.

+ 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