Hi!
I'm new to VBA so I was hoping for some help with my macro:
What I am trying to do:
I want to find all cells with a specific text (for example "a"), and then write a number in the cell to the right of the found cell (for example "1")
I no have tried for a while, and here is what I have got for now:
Sub find()
Range("b5:b35").Select
Selection.find(what:="a", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
If Not ActiveCell Is Nothing Then Range(ActiveCell, ActiveCell.End(xlToRight)).Select
With ActiveCell.Offset(0, 1)
.Value = "1"
End With
End Sub
But it doesn't run as I hoped:
- Even if there are different cells with "a" within the range, I only get "1" written in one of the cells right of one "a" cell. I want to be able to get "1" next to all cells with "a" within the range.
- Even if I run my macro more times, I will only get one cell with "1" in (and it is the exact same cell).
Can someone please help me with a tip, correction or a link to some suitable information?
Bookmarks