ITALIAORIANA
Technical User
Hi, I found the code at the bottom on this site and I have been trying to modify and have been unsuccessful. I have thousands of rows of data and I need to break the data out by adding a blank row based on values in column 2. Any help would be greatly appreciated.
When the cell value changes in column 2 from 1 to 2, I want to insert one blank row after the end of the first value. When it changes from 2 to 3, I want to insert one blank row etc... The numbers will not necessarily be consecutive but they are grouped together.
My current data:
Column 1, Column 2
A435, 1
B792, 1
C456, 1
DD58, 1
F556, 2
G887, 2
HAA, 2
J5684, 25
LADF, 30
NAD6F4, 790
KSF, 1000
L65, 1000
I want it to be:
A435, 1
B792, 1
C456, 1
DD58, 1
F556, 2
G887, 2
HAA, 2
J5684, 25
LADF, 30
NAD6F4, 790
KSF, 1000
L65, 1000
The code below works but adds a blank row in between every row. I
[pre]Dim rval As String, i As Long
rval = Cells(1, 2): i = 2
Do Until Trim(Cells(i, 1) & "") = ""
If Cells(i, 1) <> rval Then
rval = Cells(i, 1)
Rows(i).Insert shift:=xlDown
i = i + 1
End If
i = i + 1
Loop[/pre]
Thanks
Deana
When the cell value changes in column 2 from 1 to 2, I want to insert one blank row after the end of the first value. When it changes from 2 to 3, I want to insert one blank row etc... The numbers will not necessarily be consecutive but they are grouped together.
My current data:
Column 1, Column 2
A435, 1
B792, 1
C456, 1
DD58, 1
F556, 2
G887, 2
HAA, 2
J5684, 25
LADF, 30
NAD6F4, 790
KSF, 1000
L65, 1000
I want it to be:
A435, 1
B792, 1
C456, 1
DD58, 1
F556, 2
G887, 2
HAA, 2
J5684, 25
LADF, 30
NAD6F4, 790
KSF, 1000
L65, 1000
The code below works but adds a blank row in between every row. I
[pre]Dim rval As String, i As Long
rval = Cells(1, 2): i = 2
Do Until Trim(Cells(i, 1) & "") = ""
If Cells(i, 1) <> rval Then
rval = Cells(i, 1)
Rows(i).Insert shift:=xlDown
i = i + 1
End If
i = i + 1
Loop[/pre]
Thanks
Deana