+ Reply to Thread
Results 1 to 6 of 6

Issue with For Each Formula

  1. #1
    Registered User
    Join Date
    03-20-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Issue with For Each Formula

    Hi, hopefully someone can help me with this issue.

    I have a sheet setup basically like this:

    Column A ... Column G
    Plant1 $10
    Plant9 $14
    Plant1 $12
    Plant12 $15
    Plant5 $20
    ...
    Plant10 $25

    I want to loop down A14:A24 and check if any of the cells contain "Plant 1" through "Plant 7". If they contain any of those plants I then want it to
    loop through G14:G24 and multiply the corresponding value in that row by 1.1

    I have the following code so far:
    Please Login or Register  to view this content.
    It's working so far that it loops through both columns but instead of multiplying by 1.1 it seems to be multiplying by 2.85?

    Any idea what could be causing this? I'm always open to recommendations to simplify the code.

    Thanks.

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Issue with For Each Formula

    Hi there,

    this is the first thing I could think of and maybe I am not right, bu

    You loop 10x over one cell and always multiple its value by 1.1.

    I think that your initial value is 1.1
    Then
    1.1x1.1x1.1x1.1x1.1x1.1x1.1x1.1x1.1x1.1x1.1=2.85.

    Check it for sure
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,890

    Re: Issue with For Each Formula

    Deleted. Response was not relevant. I think that M.R. has it figured.
    Last edited by alansidman; 05-21-2014 at 04:49 PM.
    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

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Issue with For Each Formula

    justinpeeler,

    1. What version of Excel and Windows are you using?

    2. Are you using a PC or a Mac?


    A14:A24 and check if any of the cells contain "Plant 1" through "Plant 7"
    Your description above indicates that the plant name/type contains a space character.

    But, your macro code indicates that the plant name/type are:
    Plant1
    Plant 2
    thru
    Plant 7

    What are the correct plant names?

    And, you only have to loop thru range A14:A24 to check the correct plant name, and, if found, do the math in G14:G24.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  5. #5
    Registered User
    Join Date
    03-20-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Issue with For Each Formula

    And, you only have to loop thru range A14:A24 to check the correct plant name, and, if found, do the math in G14:G24.
    This was my problem right there.

    I removed the nested "For Each" so it only loops through column A then applies the math in column G and now everything is working correctly.

    Thank you for the help!

  6. #6
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Issue with For Each Formula

    justinpeeler,

    Thanks for the feedback.

    You are very welcome. Glad I could help.

    And, come back anytime.

+ 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. Lookup Formula Issue, Search issue
    By kperitz in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-07-2014, 01:50 PM
  2. [SOLVED] #VALUE formula issue
    By v2k2apj in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-29-2013, 06:03 PM
  3. #DIV/0! issue - cant get rid of it within another formula
    By skymaster in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-12-2007, 09:36 AM
  4. An issue regarding the formula
    By HuaMin in forum Excel General
    Replies: 2
    Last Post: 12-07-2005, 11:45 AM
  5. [SOLVED] An issue regarding the formula
    By HuaMin in forum Excel General
    Replies: 0
    Last Post: 12-07-2005, 08:35 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