apoorvaOlly
New Member
- Joined
- Jan 11, 2020
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
I need to separate my data by vendor by adding three rows in between each new vendor and then I need to add a header before each new grouping. I have the following code to enter 3 blank rows between each vendor group. In the 3rd row, I want the headers to be added. So if the data set is:
Vendor Order#
A 123
A 342
B 654
B 654
C 234
C 964
I want it to look like this:
Vendor Order#
A 123
A 342
Vendor Order#
B 654
B 654
Vendor Order#
C 234
C 964
I also need the rows with the same Order#s to be enclosed in a thick border. So both rows of vendor B would be surrounded by a thick border. I'm thinking this will be a loop as well.
Thanks!
My code:
Vendor Order#
A 123
A 342
B 654
B 654
C 234
C 964
I want it to look like this:
Vendor Order#
A 123
A 342
Vendor Order#
B 654
B 654
Vendor Order#
C 234
C 964
I also need the rows with the same Order#s to be enclosed in a thick border. So both rows of vendor B would be surrounded by a thick border. I'm thinking this will be a loop as well.
Thanks!
My code:
VBA Code:
Sub Insert_Groupings()
Dim LastRow As Long
Dim i As Integer
Application.ScreenUpdating = False
Worksheets("Picklist").Activate
LastRow = Range("A" & Rows.Count).End(xlUp).Row
' insert 3 empty rows between each Vendor
For i = LastRow To 3 Step -1
If Cells(i, 1) <> Cells(i - 1, 1) Then
Rows(i).Resize(3).Insert
End If
Next i
Application.ScreenUpdating = True
End Sub