Hello boys,
I created a VBA function to count instances of a string across sheets. Here it is
This is all fine, but I now need this to be turned into a subroutine where I can execute the procedure and it will fill all the cells I want with the result of the FindString function above. I just can't figure out how to bring the function into a procedure. This is how far I have got...
(I have a list of values in a column which I select, then all the values adjacent to the column are filled with the result of the FindString procedure)
which is obviously wrong as I'm just writing out code the way I want to it to perform in my head!
Any ideas???.... will be very appreciated with big cyber hugs!
Thank yoouuuu
I created a VBA function to count instances of a string across sheets. Here it is
Code:
Private Function FindString(c01)
For Each sht In ActiveWorkbook.Sheets
If Not sht.Name = "LIST" Then
x = WorksheetFunction.CountIf(sht.UsedRange, c01)
xcount = x + xcount
End If
Next
FindString = xcount
End Function
This is all fine, but I now need this to be turned into a subroutine where I can execute the procedure and it will fill all the cells I want with the result of the FindString function above. I just can't figure out how to bring the function into a procedure. This is how far I have got...
(I have a list of values in a column which I select, then all the values adjacent to the column are filled with the result of the FindString procedure)
Code:
Public Sub FindString()
FirstRow = Range(Left(ActiveCell.Address(RowAbsolute, ColumnAbsolute), 1) & "1").Offset(1, 0)
LastRow = Range(Left(ActiveCell.Address(RowAbsolute, ColumnAbsolute), 1) & Rows.Count).End(xlUp).Row
For i = FirstRow To LastRow
Cells(i, ActiveCell.Column).Offset(0, 1) = FindString
Next
End Sub
which is obviously wrong as I'm just writing out code the way I want to it to perform in my head!
Any ideas???.... will be very appreciated with big cyber hugs!
Thank yoouuuu