I have written below code which should write "Starting with G" in column C, if column B contains a word starting with G.
however, this highlighted word in below line generates an error saying "Compile error: Expected Array".
Below is the completed code I managed to write.
I am unable to understand why it is asking for an array when my function already has an argument "text as String".
I am going crazy tying to figure out the reason.
however, this highlighted word in below line generates an error saying "Compile error: Expected Array".
Rich (BB code):
If Not islike(cell.text, "g*") Then
Below is the completed code I managed to write.
VBA Code:
Sub trial()
Dim islike As Boolean
Dim cell As Range
For Each cell In Range("B1:B7")
If Not islike(cell.text, "g*") Then
cell.Offset(0, 1).text = "Starting with G"
Else
cell.Offset(0, 1).text = "Not Starting with G"
End If
Next cell
End Sub
VBA Code:
Public Function islike(text As String, pattern As String) As Boolean
islike = UCase(text) Like UCase(pattern)
End Function
I am unable to understand why it is asking for an array when my function already has an argument "text as String".
I am going crazy tying to figure out the reason.