I can modify this if you need a different behavior depending on which columns are empty. Addition and Subtraction in Two Columns 4. Subtracting and Adding Multiple Cells from One Cell 2.1 Using Minus (-) Sign 2.2 Using SUM Function 3. This will return 0 if both fields are empty, C if only B is empty and -B if only C is empty. Subtracting and Adding Cell References in One Formula 2. In RESULTS, use the following formula (put this one in row number 1 and copy it down): =VLOOKUP(A1,DATA!A:C,3,FALSE)-VLOOKUP(A1,DATA!A:C,2,FALSE) This function will add up the values in each column and then. If I didn't understand your question correctly, feel free to comment and clarify and I will propose something else.Įdit for VLOOKUP solution: I'm assuming that the client IDs are in column A in both tabs and you have to substract B from C in the same row as the ID in the DATA tab. If you want to subtract multiple columns from each other, you can do so by using the SUM function. If one of the two columns is empty, it won't do anything, which is what you want. Sub CalculateDuration () Dim duration As Date I basically want this to mean search down row D (Difference of time column) for values that are greater than 6 minutes duration Cells (Rows.Count, 'D').End (xlUp). The IF condition checks if both DATA!B1 and DATA!A1 are not empty, in which case it means they both have data and it will substract it. In the results tab, you could just type =IF(AND(DATA!B1"",DATA!A1""),DATA!B1-DATA!A1,"")Īnd copy the formula down the whole column. I don't actually get why you need to use VLOOKUP to substract two columns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |