Home » excel » vba – How to make Macro written on 32 bit Excel 2016 work on 64 bit Excel 2016

vba – How to make Macro written on 32 bit Excel 2016 work on 64 bit Excel 2016

Posted by: admin May 14, 2020 Leave a comment

Questions:

A macro was originally created on a 64 bit excel 2016 version (from Office 365) but I have been working on it in my 32 bit 2016 version (from Office 365). The macro works perfectly on my 32 bit computer. However, the person I am working on it for is using the 64 bit version of Excel 2016, and they say it keeps crashing for them, but it is inconsistent, crashing in different places all the time and even occasionally running properly. The code DOES NOT contain any declare statements or longs, so I am not sure why this is happening or what to do about it. Any help regarding how to fix this or what the problem is would be much appreciated. Thank you. A copy of the code that has been crashing is included below.

Sub Formulas()

Dim rows As String

rows = CStr(Range("Sheet1!C31").Value)

Range("Sheet2!M2:M" & rows).Formula = "=((F2*1000)-(Sheet1!$C$13*(COS(2*PI()*(Sheet1!$C$15/360)))))*-1"
Range("Sheet2!N2:N" & rows).Formula = "=IF(G2<0,0,((G2+Sheet1!$C$19+Sheet1!$C$21)*Sheet1!$C$17))"
Range("Sheet2!O2:O" & rows).Formula = "=M2+N2"
Range("Sheet2!P2:P" & rows).Formula = "=O2/Sheet1!$C$23"
Range("Sheet2!Q2:Q" & rows).Formula = "=IF(OR(P2>(Sheet1!$C$25),P2<(Sheet1!$C$26)),1,0)"
Range("Sheet2!R2:R" & rows).Formula = "=IF(H2>0,1,0)"
Range("Sheet2!S2:S" & rows).Formula = "=IF(AND(Q2=1),(R2=1)*1,0)"
Range("Sheet2!B17").Formula = "=1-(SUM(S:S)/SUM(R:R))"
Range("Sheet1!C28") = Range("Sheet2!B17")

'Do While Not IsEmpty(ActiveCell.Value)
'     Range("Sheet2!M" & CStr(ActiveCell.Row)).EntireRow.Delete
'Loop


End Sub

I am fairly new to vba and macros, so if someone could point out what aspect of the code is incompatible in 64 bit or even suggest how to fix it, I would be extremely grateful. Thank you.

How to&Answers:

The code ended up being fine. We had to do a registry hack as posted under the “Registry Information” section here: https://support.microsoft.com/en-us/help/3085435/august-8-2017-update-for-excel-2016-kb3085435