Convert Excel IF command to VBA

Status
Not open for further replies.

krass

New Member
Joined
Nov 14, 2014
Messages
5
I have af growing Worksheet (daily update) which has an IF command (in Col L) to calculate the difference between two cells in Col E - but only if value in Col A is identical. The IF command looks like this: =IF(A2<>A1;E2-0;E2-E1) and is placed in Col L

If the worksheet has been sorted eg. by Date, it would be nice to have it sorted by User number first, else, I believe nothing would work?


ABCDEFGHIJKL
1UserDistrictDateNumberConsumptionTemp1Temp2Temp3Temp4Temp5Diff
2100127-07-2018780173320,19932,5963,4330,4838,6-8,12-0,0162 0,199
3100128-07-2018780173320,20532,763,2730,6138,6-7,99-0,0164 0,006
4100129-07-2018780173320,20932,6263,3430,4938,6-8,11-0,0169 0,004
5100130-07-2018780173320,21532,663,3230,5138,6-8,09-0,0174
6100131-07-2018780173320,22332,7863,4230,638,6-8-0,0178
7100101-08-2018780173320,22632,6663,3630,5938,6-8,01-0,0181
8100102-08-2018780173320,23432,7763,3630,4638,6-8,14-0,019
9200101-07-2018781710360,01429,3660,9831,7139,2-7,49-0,001
10200102-07-2018781710360,02529,4560,2730,1439,5-9,36-0,0023
11200103-07-2018781710360,03929,4260,5329,8239,2-9,38-0,0037
12200104-07-2018781710360,05229,4260,5330,2639,2-8,94-0,0046
13200105-07-2018781710360,06929,9660,6130,339,2-8,9-0,0061
14200106-07-2018781710360,09130,4561,0930,3539,2-8,85-0,0081
15200107-07-2018781710360,11230,5761,5930,4838,9-8,42-0,0094
15200108-07-2018781710360,13531,0461,7630,4838,9-8,42-0,0114
17200109-07-2018781710360,15331,0361,7930,4238,9-8,48-0,013

<tbody>
</tbody>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi there

I'm not sure I understand the question - couldn't you sort on column A first then column C? The formulas should look after themselves.
 
Upvote 0
Duplicate https://www.mrexcel.com/forum/excel-questions/1065545-if-command-loop-into-vba.html#post5117246

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).


Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,453
Messages
6,124,925
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top