+ Reply to Thread
Results 1 to 7 of 7

Loop + "or"

Hybrid View

  1. #1
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: Loop + "or"

    I don't know why but it seems to me you have a problem with the original formula:

    =IF((IF(OR(C3=0;B3=0;D3=0;E3=0;F3<=0);0;A4- A3))<0;0;IF(OR(C3=0;B3=0;D3=0;E3=0;F3<=0);0;A4-A3))
    if you already check if OR(C3=0;B3=0;D3=0;E3=0;F3<=0) in the TRUE part of the formula, why do you check it second time in the OR(C3=0;B3=0;D3=0;E3=0;F3<=0)
    ??
    If the BLUE condition meets then the RED one is redundant.
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  2. #2
    Registered User
    Join Date
    07-20-2015
    Location
    UK
    MS-Off Ver
    2010
    Posts
    17

    Re: Loop + "or"

    hi,

    I agree the formula is too complex, but works as I have been using it for a while and gives the results I am looking for.

    I have got 7 columns:
    A contains time stamp
    B to F values

    Column H should check value in cells B to F. As long as the logical test is true, than blank(“”). If the logical test is false it should subtract time form column A.
    B to F logical test
    B=0
    C=0
    D=0
    E=0
    F<0

    I think this is covert by the VBA if

    If Cells(i, 2) = 0 Or Cells(i, 3) = 0 Or Cells(i, 4) = 0 Or Cells(i, 5) = 0 Or Cells(i, 6) < 0 Then Cells(i, 8).Value = "" Else Cells(i, 8).Value = Cells(i + 1, 1).Value - Cells(i, 1).Value
    On Error Resume Next

    All the results are saved in column H.
    Depends on quality of data I am receiving the subtract of time gives negative number, in order to avoid it I have created the VBA if, which looks for negative numbers and replace them with blank (“”)


    If Cells(i, 8) < 0 Then Cells(i, 8).Value = ""

    I think the loop approach is correct, please correct me if I am wrong.

    Is it possible to replace the long expression:

    If Cells(i, 2) = 0 Or Cells(i, 3) = 0 Or Cells(i, 4) = 0 Or Cells(i, 5) = 0
    to something like this:

    If Cells(i, j) = 0
    If yes, would it help and reduce time?


    Flooyd

+ 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] Copy cells from range "C3" to "F3" with loop and blank field
    By masterm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2015, 01:03 PM
  2. Replies: 1
    Last Post: 11-04-2015, 04:34 AM
  3. [SOLVED] How can I change "A" to "B" using a loop or operation?
    By nim73n in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2014, 03:48 AM
  4. [SOLVED] Replace multiple "If Then" with "For" loop
    By checkltout in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 10:56 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. [SOLVED] Loop to check for "yes" then copy the IDs with "yes" and paste to other workbook
    By Hallet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2012, 12:41 PM

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