Convert Excel 2003 to 2007 or latest version with VBA

I have an excel xls file (excel 97-2003 workbook) that has vba code in it. I want to convert it to 2007 or newer version of excel with vba code included. I tried:

  • save as macro-enabled.xlsm file
  • changed the macro settings for this blog. he changed the document in .xlsm, but for the values ​​of the cell (on which the macro is executed) he shows #NAME instead of values. Original file: enter image description here

is converted: enter image description here I'm stuck here.

macro code:

1.moveAcross.bas

Attribute VB_Name = "MoveAcross" Sub GoToValues() Attribute GoToValues.VB_Description = "Macro recorded 23-01-2001 by Murad Assaggaf" Attribute GoToValues.VB_ProcData.VB_Invoke_Func = " \n14" ' ' GoToValues Macro ' Macro recorded 23-01-2001 by Murad Assaggaf ' ' ActiveWindow.SmallScroll ToRight:=13 ActiveWindow.LargeScroll Down:=-2 ActiveWindow.SmallScroll Down:=-3 ActiveWindow.SmallScroll ToRight:=2 Range("X6").Select End Sub Sub ReturnToProfileArea() Attribute ReturnToProfileArea.VB_Description = "Macro recorded 23-01-2001 by Murad Assaggaf" Attribute ReturnToProfileArea.VB_ProcData.VB_Invoke_Func = " \n14" ' ' ReturnToProfileArea Macro ' Macro recorded 23-01-2001 by Murad Assaggaf ' ' Range("G5").Select End Sub 

2.Demand.bas

 Attribute VB_Name = "Demand" Function Demand(m0, m1, m2, m3, m4, m5, m6, EndInv, ST, Fraction) Static months(7) As Variant months(0) = m0 months(1) = m1 months(2) = m2 months(3) = m3 months(4) = m4 months(5) = m5 months(6) = m6 Dim summy summy = 0 If Fraction > 0 Then summy = months(ST + 1) * Fraction End If For n = 0 To ST summy = summy + months(n) Next n Demand = summy - EndInv If Demand < 0 Then Demand = 0 End If End Function 

3.Coverage.bas

 Attribute VB_Name = "Coverage" Function Coverage(m0, m1, m2, m3, m4, m5, m6, EndInv, ST, Fraction) Static months(7) As Variant months(0) = m0 months(1) = m1 months(2) = m2 months(3) = m3 months(4) = m4 months(5) = m5 months(6) = m6 Dim summy summy = 0 If Fraction > 0 Then summy = months(ST) * Fraction End If For n = 0 To (ST - 1) summy = summy + months(n) Next n Coverage = EndInv / (summy / (ST + Fraction)) End Function 

Edited screenshot of VBA: enter image description here

+5
source share
2 answers

Check in the VB editor -> Tools -> Links, if there are any libraries selected since MISSING: enter image description here

If yes, deselect and try again.

+1
source

You need to put the code in "ThisWorkbook" if you want to call it on a worksheet.

0
source

Source: https://habr.com/ru/post/1261940/


All Articles