Hi all,
I have a simple question about a vba macro i created.
This is a macro where if a certain string "anumber" does not exist in Column A, it will add that string to the end of the column.
The problem, however is that it's failing to add some specific strings. For example,
Let's say my excel column A contains:
Sports15
Sports14
Sports12
Sports25
And I want to add Sports1 to the end of the column. It fails to do so because when you search for Sports1, it actually finds Sports15, and it thinks that Sports1 exists in the column.
How can I make it so that it has to match the exact string?
Any help would be appreciated.
Thanks in advance!
I have a simple question about a vba macro i created.
This is a macro where if a certain string "anumber" does not exist in Column A, it will add that string to the end of the column.
Code:
Dim anumber As String
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rfind = .Range("A1:A" & LastRow).Find(anumber)
If rfind Is Nothing Then
If .Range("A" & .Rows.Count).End(xlUp).Offset(-1, 0).Value = "" Then
.Range("A" & .Rows.Count).End(xlUp).Offset(-1, 0).Value = anumber
Else:
.Range("A" & .Rows.Count).End(xlUp).Insert (xlDown)
.Range("A" & .Rows.Count).End(xlUp).Offset(-1, 0).Value = anumber
End If
The problem, however is that it's failing to add some specific strings. For example,
Let's say my excel column A contains:
Sports15
Sports14
Sports12
Sports25
And I want to add Sports1 to the end of the column. It fails to do so because when you search for Sports1, it actually finds Sports15, and it thinks that Sports1 exists in the column.
How can I make it so that it has to match the exact string?
Any help would be appreciated.
Thanks in advance!