I'm making a function on Excel VBA that does many cleaning tasks on a big Excel sheet. It is supposed to contain multiple subroutines. The individual subroutines work, but I can't seem to make the calls work properly.
Public Function CleanTable(rangeA As Range)
Module1.replaceCellWithZero (rangeA)
Module2.removeAsterisk (rangeA)
End Function
Public Function ReplaceCellWithZero(rangeA As Range)
Dim thisCell As Variant
For Each thisCell In rangeA
If InStr(thisCell, "<") > 0 Then
thisCell.Value2 = 0
End If
Next thisCell
End Function
Public Function removeAsterisk(rangeA As Range)
Dim thisCell As Variant
For Each thisCell In rangeA
thisCell.Value2 = replace(thisCell, "*", "")
Next thisCell
End Function
When I call the CleanTable function, it just doesn't seem to do anything. I couldn't find what the matter is even with debugging. It seems like it just stops at the replaceCellWithZero.
The main function is a function and not a sub because the function will need to be utilized in a big amount of different Excel documents. I believe subs would require either buttons or manual inputting of range areas in the code, which doesn't suit the needs of this thing. The subs are in different modules because the files may need to be shared separately.
Any help would be appreciated!
Subcan have arguments just like aFunction.Subs personally - but remove the parentheses aroundrangeA.Functionsdo away with "manual inputting of range areas in the code"? How are you calling the first function?Module1.replaceCellWithZero (rangeA)as the parenthesis will first evaluate rangeA and then you pass a Variant instead of a range to the function. So, as BigBen wrote, remove the parenthesis.