PDA

View Full Version : Solved: move data with * symbol to another sheet



parscon
05-13-2012, 04:38 AM
I have some number that some of them have symbol * in end of them like

12121212*
1212*
23434343423*
1121212*
_232323232*
232323BK*
BK_w23232_*


Now i need a macro that copy them (row)(data that have star) to sheet 2 and delete row from sheet 1 .

Thank you so much for your big help .

GTO
05-13-2012, 05:19 AM
Not well tested, maybe:
Option Explicit

Sub example()
Dim ary1 As Variant
Dim ary2 As Variant
Dim n As Long
Dim x As Long

With Sheet1

ary1 = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp)).Value
ReDim ary2(1 To UBound(ary1, 1), 1 To 1)
x = UBound(ary1, 1)

For n = UBound(ary1, 1) To 1 Step -1
If Right(ary1(n, 1), 1) = "*" Then
ary2(x, 1) = ary1(n, 1)
x = x - 1
.Cells(n + 1, 1).Delete xlShiftUp
End If
Next
End With

Sheet2.Range("A2").Resize(UBound(ary2, 1)).Value = ary2
If x >= 2 Then
Sheet2.Rows("2:" & x + 1).Delete
End If
End Sub
Hope that helps,

Mark

parscon
05-13-2012, 05:50 AM
it is work , thank you for your big help .

GTO
05-14-2012, 05:48 AM
Happy to help :beerchug: