Vlookup formula - works with F9 - does not work with simple 'calculate' Macro

Jamie McMillan

Board Regular
Joined
Nov 8, 2021
Messages
169
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a simple vlookup formula, =IF(C13=0,"",VLOOKUP(C13,$A$13:$B$27,2))

It works properly when I press F9 (Excel is on manual calculation)

I use two very simple macros to calculate the sheet: then it does not work.

The first macro 'EveryOne' is attached to a shape (Labelled 'Any' in the attached image - the result is also on the image.)

(It sometimes works; but then, maybe 1 it 10 tries it fails.)????

VBA Code:
Sub EveryOne()
    Range("A3").Value = 3
    Call HowLong
End Sub

Sub HowLong()
    Range("B1").Value = 0
    Calculate
End Sub

Crazy!!!

Thanks for anything. :) (I have closed it and reopened the file, and restarted Excel.)

Jamie
 

Attachments

  • Strange Result.jpg
    Strange Result.jpg
    165.3 KB · Views: 8

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hello,

I solved it. :) :) :)

If it happens to anyone else.

The number that was being looked up was not 14. it was 14.00000000000000000001

It was subtracting two Int(values) ; so should always have been an integer.

I simply rounded it, now it always works. =ROUND(D7,1)

Thanks to anyone who thought about it.

Jamie
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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