User Profile
Andrew_Duncan54
Brass Contributor
Joined Mar 05, 2018
User Widgets
Recent Discussions
Re: Runtime error 6 overflow with Dim Double. MacOS Catalina - Excel 2019 - VBA 7.1
PeterGallin Same problem is occurring with MacOS 13.5.1, MS Excel for Mac 16.78, Office 365. Sub test2() Dim a As Long Dim b As Long a = 0 b = 10 Debug.Print a; b a = b 'a = Round(b, 10) Debug.Print a; b End Sub This generates a Run-time error '6'. If the type is changed to any other numeric type the problem does not occur. If the to be assigned variable is processed by a function such as Round (see comment line in code) the error does not occur.2.4KViews0likes2CommentsRe: VBA code for inputs
Not quite sure what you are attempting, as I'm not familiar with Matlab. But the guts of your function should look much the same as what you have written: Function someFunction(y As Variant) As Variant Dim growth() As Variant Dim i As Long ReDim growth(LBound(y) To UBound(y)) For i = 1 To UBound(y) - 1 If y(i) < 0 And y(i + 1) < 0 Then growth(i) = y(i) / y(i + 1) ElseIf y(i) > 0 And y(i + 1) > 0 Then growth(i) = y(i + 1) / y(i) ElseIf y(i) < 0 And y(i + 1) > 0 Then growth(i) = (y(i + 1) - (y(i)) / (-y(i))) Else growth(i) = 0 End End someFunction = growth End Function If you paste your raw data into an excel spreadsheet as a single row or column. In another cell reference, the function "someFunction" (or whatever you have called it), for the function input, have the range of cells referring to your input data (i.e. A1:A100, etc), the above code will return an array of growth values. With the lower bit of code, not quite sure what that is doing. Excel has good inbuilt functions for generating AVERAGE. Either use excels Functions to process the output or put the cove into the VBA Function. Hope this helps.1.1KViews0likes0Comments
Recent Blog Articles
No content to show