Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

Writing into Excel worksheet from custom VBA function (not sub)

$
0
0
Hello Everyone!
I would greatly appreciate your assistance in helping me write data from a custom VBA function into an excel worksheet. I have been able to write from a custom VBA subroutine but get an error whilst executing a VBA function. In the sample code, "Sub write 2" and "Sub write 3" work just fine. But "Function test 2()" generates "Value!" in its cell and write3 isn't executed.

Sub write2(r As Integer, c As Integer, d As Double)
Dim a, b As Integer
For a = r To r + 1
For b = c To c + 1
Cells(a, b).Value = d
Next b
Next a
End Sub

Sub write3()
Call write2(3, 60, 0.437)
End Sub

Function test2() As Double
Call write3
test2 = 1#
End Function

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>