Hello, thank you for your help.
I am attempting to call a Function from a cell and pass it a range and an Integer. The Integer works fine, but I cannot get the Range to pass into the function correctly.
'This code is from the cell **doesn't work, i get "#NAME?"
=BS(JuneAll,3)
'also tried:
=BS("A1:G26",3)
'I have also tried calling it from a button_click:
Private Sub CommandButton1_Click()
Range("V8") = BS(Range("A1:G26"), 3)
End Sub
Function BS(rng As Range, iRow As Integer)
'Test operations
countt = 0
With Sheets("Utilization").Range(rng).Rows(iRow).Select
For Each c In Selection
If c.Interior.ColorIndex = 37 Then countt = countt + 1
Next
End With
BS = countt
End Function
If I remove the ".Range(rng)" the code works but for the entire Row and not just the portion of the row inside my Range.
If I replace ".Range(rng)" with ".Range("A1:G26")" it works correctly.
Part 2:
When it is working through the button_click, it still does not work when called directly from a cell why is that?
Herre is the code referenced in the cell:
Can anyone help? thx
Bookmarks