BobNewsome
New Member
- Joined
- Oct 11, 2016
- Messages
- 4
I have a macro where I'm trying to cut rows out of one sheet and place in another based on a partial data string in the cell.
Data:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]1111-1000-8[/TD]
[/TR]
[TR]
[TD]1111-1001-8[/TD]
[/TR]
[TR]
[TD]1111-2000-8[/TD]
[/TR]
[TR]
[TD]1111-2000-8[/TD]
[/TR]
[TR]
[TD]1111-2001-8[/TD]
[/TR]
</tbody>[/TABLE]
Code:
The VBA is only finding the first 2 "1111-2000" but when the second qualifier changes ie "2001" it does not capture it. How do I get the code to capture ALL of the "1111-2" regardless of the next characters?
Thanks.
Data:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]1111-1000-8[/TD]
[/TR]
[TR]
[TD]1111-1001-8[/TD]
[/TR]
[TR]
[TD]1111-2000-8[/TD]
[/TR]
[TR]
[TD]1111-2000-8[/TD]
[/TR]
[TR]
[TD]1111-2001-8[/TD]
[/TR]
</tbody>[/TABLE]
Code:
Code:
Sub Macro1()'
Dim myrange As Range
Dim myvalue As String
myvalue = Range("A1:A2000").Find(What:="1111-2", LookIn:=xlFormulas)
'
For Each Cell In Range("A1:A2000")
If Cell.Value = myvalue Then
If myrange Is Nothing Then
Set myrange = Range(Cell.Address)
Else
Set myrange = Union(myrange, Range(Cell.Address))
End If
End If
Next
myrange.Select
Selection.Cut
End Sub
The VBA is only finding the first 2 "1111-2000" but when the second qualifier changes ie "2001" it does not capture it. How do I get the code to capture ALL of the "1111-2" regardless of the next characters?
Thanks.