I have made some code in VBA and when running it manually it runs just fine. My problem is when assigning the code to a button in Excel it runs the full script, but misses out on a calculation in the script (the column where the calculations is supposed to be at is empty). Anyone who knows why?
My code for the calculation in VBA looks like this and is part of a larger script:
'Calculate Share of portfolio %
secondvalue = WorksheetFunction.Sum(Range("B6:B" & m))
For m = 6 To Rows.Count
If Cells(m, 2).Value <> "" Then
Cells(m, 3).Value = Cells(m, 2).Value / secondvalue
End If
Next m