Consulting

Results 1 to 4 of 4

Thread: Code for multiplying 2 values based on search

  1. #1
    VBAX Regular
    Joined
    Oct 2014
    Posts
    24
    Location

    Cool Code for multiplying 2 values based on search

    Hi everyone,

    I have somewhat of a strange task... I'm looking for VBA code to multiply 2 numbers beside each other. However, it needs to be done based on a certain range of cells.

    P 12 22
    EEOG 2
    X 10 65
    X 61 62
    EEOG 3
    L 26
    L
    K 5 56
    EEOG 5
    L
    EEOG 10
    A 11 12
    A
    H 2 5
    EEOG 20

    For example, I'm looking for code that will search column A in the table above for string "EEOG". Then, for each string within the parameters of "EEOG" I want the 2 values beside it multiplied, and put in column 4. So, the resulting table would look like this...

    P 12 22
    EEOG 2
    X 10 65 650
    X 61 62 3782
    EEOG 3
    L 26
    L
    K 5 56 280
    EEOG 5
    L
    EEOG 10
    A 11 12 132
    A
    H 2 5 10
    EEOG 20

    I was thinking of somehow incorporating the End(xlDown) function to search for the range and fill in an equation, but notice how some values between "EEOG" are blank.

    Any help or feedback on this would be greatly appreciated.

    Thanks in advance!!

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Column D Formula is =IF(A<>"EEOG",B*C,"")
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Oct 2014
    Posts
    24
    Location
    @SamT could you wrap the "ISERROR" function in there? I'm trying to add it with little success.

    *Edit...

    Found it!

    =IF(ISERROR((IF(A1<>"EEOG",B1*D1,""))),"",IF(A1<>"EEOG",B1*D1,""))
    Last edited by Johnatha; 01-20-2016 at 01:27 PM.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    =IF(ISERROR(B1*C1),"",IF(A1<>"EEOG",B1*C1,""))

    If B1*C1 Fails Then nothing Else original Formula
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •