Help me in writing macro
Sub MoveData()
Dim iLastRow As Long
Dim iRow1 As Long
Dim iRow2 As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "C").End(xlUp).Row
'ignore initial blank rows
iRow1 = 1
Do Until Cells(iRow1, "C").Value < ""
iRow1 = iRow1 + 1
Loop
iRow2 = iRow1
For i = iRow1 To iLastRow
If Left(Cells(i, "C").Value, 1) = "A" Then
If i < iRow1 Then
Cells(iRow1, "C").Value = Cells(i, "C").Value
Cells(i, "C").Value = ""
End If
iRow1 = iRow1 + 1
Else
Cells(iRow2, "B").Value = Cells(i, "C").Value
Cells(i, "C").Value = ""
iRow2 = iRow2 + 1
End If
Next i
End Sub
--
HTH
Bob Phillips
"kishore" wrote in message
oups.com...
I forgot to put the sample of the file, I wanted to do it using macro,
so that i can call this in my existing macro.
Col A Col B Col C Col D
Col E
1
2
3
4 A12345
5 A23456
6 A13567
7 V12345
8 V23456
9 V13567
What I want is a macro which do the following:
Col A Col B Col C Col D
Col E
1
2
3
4 V12345 A12345
5 V23456 A23456
6 V13567 A13567
7
8
9
Thanks guys in advance!!
|