It works for me
Option Explicit Sub Sample() Dim ret ret = test(Sheets("Sheet1").Range("A1:A15")) End Sub Function test(thisRange As Range) Dim c As Range For Each c In thisRange.Cells c.Value = 1 Next End Function
By the way, we do not need to use the function. The function returns a value. try it
Option Explicit Sub Sample() test Sheets("Sheet1").Range("A1:A15") End Sub Sub test(thisRange As Range) Dim c As Range For Each c In thisRange.Cells c.Value = 1 Next End Sub
source share