Change formula to code

novice1

Board Regular
Joined
Dec 11, 2007
Messages
146
Can some assist in changing the formula into code. Thanks for you help

=(SUMIF(Logbook!$A9:$A10009,">="&A5-6,Logbook!$E9:$E10009)-SUMIF(Logbook!$A9:$A10009,">"&A5,Logbook!$E9:$E10009))/24
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Not sure what you are doing with it, but this should do what you want I think?

decValue = evaluate("=(SUMIF(Logbook!$A9:$A10009,"">=""&A5-6,Logbook!$E9:$E10009)-SUMIF(Logbook!$A9:$A10009,"">""&A5,Logbook!$E9:$E10009))/24")

Hope that helps.
 
Upvote 0
Or something like this...

Code:
    Dim rngA As Range, rngE As Range
    
    Set rngA = Sheets("Logbook").Range("A9:A10009")
    Set rngE = Sheets("Logbook").Range("E9:E10009")
    
    x = (Application.SumIf(rngA, ">=" & Range("A5") - 6, rngE) - _
         Application.SumIf(rngA, ">" & Range("A5"), rngE)) / 24

Note: Range("A5") is referencing the ActiveSheet
 
Upvote 0
Also it seems like your formula could just be this?

=SUMIF(Logbook!$A9:$A10009,6,Logbook!$E9:$E10009)/24

But maybe I am missing something here?
 
Upvote 0
Not sure what you are doing with it, but this should do what you want I think?

decValue = evaluate("=(SUMIF(Logbook!$A9:$A10009,"">=""&A5-6,Logbook!$E9:$E10009)-SUMIF(Logbook!$A9:$A10009,"">""&A5,Logbook!$E9:$E10009))/24")

Hope that helps.


I think it will work, but it displays 0.483333. It should be display in time format [h]:mm
 
Upvote 0
Maybe try:

Code:
decValue = format(evaluate("=(SUMIF(Logbook!$A9:$A10009,"">=""&A5-6,Logbook!$E9:$E10009)-SUMIF(Logbook!$A9:$A10009,"">""&A5,Logbook!$E9:$E10009))/24"),"[h]:mm")
Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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