lalsigongon
New Member
- Joined
- Aug 17, 2015
- Messages
- 3
Hi
I am trying to create a VBA code that allows me to compare rows data between last month and this.
For example.
Last month
1 A
2 B
3 C
4 D
41 E
5 F
6 G
7 H
This month
1
2
2a
3
4
5
5b
6
7
8
Thus, I would manual check row by row, to ensure that the data in lastmonth is update to date. this means, I have to add in 2a and 5b as additional rows into the data file and also delete 41 before I could use the file.
is there anyway to automate this via macro?
I found a way to add rows but not delete unnecessary ones.
"Dim cl As Range
Set cl = Range("C1")
Do While cl.Row < 10
If cl.Value <> cl.Offset(0, 3).Value Then
cl.Offset(0, 1).Insert Shift:=xlDown
cl.Insert Shift:=xlDown
Set cl = cl.Offset(-1, 0)
End If
Set cl = cl.Offset(1, 0)
Loop
End Sub"
Might not be the best way! hope someone can help me out!
I am trying to create a VBA code that allows me to compare rows data between last month and this.
For example.
Last month
1 A
2 B
3 C
4 D
41 E
5 F
6 G
7 H
This month
1
2
2a
3
4
5
5b
6
7
8
Thus, I would manual check row by row, to ensure that the data in lastmonth is update to date. this means, I have to add in 2a and 5b as additional rows into the data file and also delete 41 before I could use the file.
is there anyway to automate this via macro?
I found a way to add rows but not delete unnecessary ones.
"Dim cl As Range
Set cl = Range("C1")
Do While cl.Row < 10
If cl.Value <> cl.Offset(0, 3).Value Then
cl.Offset(0, 1).Insert Shift:=xlDown
cl.Insert Shift:=xlDown
Set cl = cl.Offset(-1, 0)
End If
Set cl = cl.Offset(1, 0)
Loop
End Sub"
Might not be the best way! hope someone can help me out!