FelixExcel
New Member
- Joined
- Sep 14, 2022
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Hey all, Im currently working on an excel project in which I use a counter. Right now I use following code to reset the counter to 0 everytime excel is opened.
Private Sub UserForm_Initialize()
counter = 0
End Sub
I now noticed that this is actually not what I need. I would need the counter to set itself to the number a specific word, for example "hello" appears in my excel sheet. I have a feeling there is an easy solution to this, which shouldnt involve to many lines of code.
So far I made a bit of progress and found out that I can use the formular =SUMIF(range, "Text") to count how often a certain word appears in a certain range, but Im not sure how Im able to integrate this number into my vba code. Is there an option to just set my counter to the value of the cell that has the sumif formular. For example if the formular would be in the cell A2:
Private Sub UserForm_Initialize()
counter = A2
End Sub
I would appreciate any help with this.
Private Sub UserForm_Initialize()
counter = 0
End Sub
I now noticed that this is actually not what I need. I would need the counter to set itself to the number a specific word, for example "hello" appears in my excel sheet. I have a feeling there is an easy solution to this, which shouldnt involve to many lines of code.
So far I made a bit of progress and found out that I can use the formular =SUMIF(range, "Text") to count how often a certain word appears in a certain range, but Im not sure how Im able to integrate this number into my vba code. Is there an option to just set my counter to the value of the cell that has the sumif formular. For example if the formular would be in the cell A2:
Private Sub UserForm_Initialize()
counter = A2
End Sub
I would appreciate any help with this.