Hello Everyone,
I know this issue has been addressed but none of the solutions really solve my problem; hope someone can help me.
I have a spreadsheet with a lot of data that i was able to manipulate with codes and the last part is to now format with borders and blank cells between to make it easy to read (Below is a copy of the data and also what i am trying to achieve). Columns A to I have merged cells and Column J to P do not. I would like to have solid borders around my rows based on the area of the merged cells in column E but do not want borders around the single cells in Col J to P and also would like to insert a blank row every time there is a change in Col E.
I have tried may codes that did not work and was ready to just settle with just inserting a blank row just when there is a change in Columns E but considering that the col has merged cells, it is not working; it is inserting rows and not taking into account merged areas.
Please see below images of the data as is, what i want and what i was able to achieve with the code below:
Raw Data
What I want
What i Get with the code below:
Sub InsertLine()
Dim lrow As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For lrow = Cells(Cells.Rows.Count, 5).End(xlUp).Row To 2 Step -1
If Cells(lrow, 5) <> Cells(lrow - 1, 5) Then
Rows(lrow).EntireRow.Insert
Rows(lrow).Interior.ColorIndex = 15
Rows(lrow).BorderAround _
ColorIndex:=1, Weight:=xlThin
End If
Next lrow
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Thank you for all your Help in advance
I know this issue has been addressed but none of the solutions really solve my problem; hope someone can help me.
I have a spreadsheet with a lot of data that i was able to manipulate with codes and the last part is to now format with borders and blank cells between to make it easy to read (Below is a copy of the data and also what i am trying to achieve). Columns A to I have merged cells and Column J to P do not. I would like to have solid borders around my rows based on the area of the merged cells in column E but do not want borders around the single cells in Col J to P and also would like to insert a blank row every time there is a change in Col E.
I have tried may codes that did not work and was ready to just settle with just inserting a blank row just when there is a change in Columns E but considering that the col has merged cells, it is not working; it is inserting rows and not taking into account merged areas.
Please see below images of the data as is, what i want and what i was able to achieve with the code below:
Raw Data
Book1 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
1 | CO | Company | Result | Worker | Employee ID | Gross | Ded/Tax | Net | Total Paid Hours | Name | Amount | Hours | Name | Amount | Name | Amount | ||
2 | NC | Nanny and Cory | Temp | Ansadfas Cedwfsd | 12414 | 300.00 | 100.00 | 200.00 | 173.33 | Regular Salary | 200.00 | 156.00 | Apple | 38.70 | SSP | 1,006.07 | ||
3 | Regular Salary | 100.00 | 17.33 | Apple | 4.30 | MD | 235.29 | |||||||||||
4 | Orange | 342.90 | ST/ AZ | 394.32 | ||||||||||||||
5 | Eyes | 1.56 | ||||||||||||||||
6 | NC | Nanny and Cory | Temp | Closonb Jenkin | 77617 | 500.00 | 200.00 | 300.00 | 173.33 | Regular Salary | 500.00 | 173.33 | Orange | 281.00 | SSP | 550.92 | ||
7 | MD | 128.84 | ||||||||||||||||
8 | VVT | 1,048.26 | ||||||||||||||||
9 | 125.00 | 25.00 | 100.00 | Bonus | 125.00 | SSP | 77.50 | |||||||||||
10 | MD | 18.13 | ||||||||||||||||
11 | VVT | 275.00 | ||||||||||||||||
12 | ||||||||||||||||||
13 | NC | Nanny and Cory | Temp | John Doe | 12515 | 133.00 | 57.00 | 76.00 | 173.33 | Regular Salary | 133.00 | 173.33 | 33P | 1,733.34 | SSP | 810.94 | ||
14 | Apple | 19.00 | MD | 189.65 | ||||||||||||||
15 | BUS | 120.00 | CT/ NY | 436.56 | ||||||||||||||
16 | Eyes | 8.22 | FAM | 10.00 | ||||||||||||||
17 | YSD | 2.60 | ||||||||||||||||
18 | ||||||||||||||||||
Raw |
What I want
Book1 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
1 | CO | Company | Result | Worker | Employee ID | Gross | Ded/Tax | Net | Total Paid Hours | Name | Amount | Hours | Name | Amount | Name | Amount | ||
2 | NC | Nanny and Cory | Temp | Ansadfas Cedwfsd | 12414 | 300.00 | 100.00 | 200.00 | 173.33 | Regular Salary | 200.00 | 156.00 | Apple | 38.70 | SSP | 1,006.07 | ||
3 | Regular Salary | 100.00 | 17.33 | Apple | 4.30 | MD | 235.29 | |||||||||||
4 | Orange | 342.90 | ST/ AZ | 394.32 | ||||||||||||||
5 | Eyes | 1.56 | ||||||||||||||||
6 | ||||||||||||||||||
7 | NC | Nanny and Cory | Temp | Closonb Jenkin | 77617 | 500.00 | 200.00 | 300.00 | 173.33 | Regular Salary | 500.00 | 173.33 | Orange | 281.00 | SSP | 550.92 | ||
8 | MD | 128.84 | ||||||||||||||||
9 | VVT | 1,048.26 | ||||||||||||||||
10 | 125.00 | 25.00 | 100.00 | Bonus | 125.00 | SSP | 77.50 | |||||||||||
11 | MD | 18.13 | ||||||||||||||||
12 | VVT | 275.00 | ||||||||||||||||
13 | ||||||||||||||||||
14 | ||||||||||||||||||
15 | NC | Nanny and Cory | Temp | John Doe | 12515 | 133.00 | 57.00 | 76.00 | 173.33 | Regular Salary | 133.00 | 173.33 | 33P | 1,733.34 | SSP | 810.94 | ||
16 | Apple | 19.00 | MD | 189.65 | ||||||||||||||
17 | BUS | 120.00 | CT/ NY | 436.56 | ||||||||||||||
18 | Eyes | 8.22 | FAM | 10.00 | ||||||||||||||
19 | YSD | 2.60 | ||||||||||||||||
20 | ||||||||||||||||||
Raw (3) |
What i Get with the code below:
Sub InsertLine()
Dim lrow As Long
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For lrow = Cells(Cells.Rows.Count, 5).End(xlUp).Row To 2 Step -1
If Cells(lrow, 5) <> Cells(lrow - 1, 5) Then
Rows(lrow).EntireRow.Insert
Rows(lrow).Interior.ColorIndex = 15
Rows(lrow).BorderAround _
ColorIndex:=1, Weight:=xlThin
End If
Next lrow
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Book1 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | |||
1 | CO | Company | Result | Worker | Employee ID | Gross | Ded/Tax | Net | Total Paid Hours | Name | Amount | Hours | Name | Amount | Name | Amount | ||
2 | ||||||||||||||||||
3 | NC | Nanny and Cory | Temp | Ansadfas Cedwfsd | 12414 | 300.00 | 100.00 | 200.00 | 173.33 | Regular Salary | 200.00 | 156.00 | Apple | 38.70 | SSP | 1,006.07 | ||
4 | ||||||||||||||||||
5 | Regular Salary | 100.00 | 17.33 | Apple | 4.30 | MD | 235.29 | |||||||||||
6 | Orange | 342.90 | ST/ AZ | 394.32 | ||||||||||||||
7 | Eyes | 1.56 | ||||||||||||||||
8 | ||||||||||||||||||
9 | NC | Nanny and Cory | Temp | Closonb Jenkin | 77617 | 500.00 | 200.00 | 300.00 | 173.33 | Regular Salary | 500.00 | 173.33 | Orange | 281.00 | SSP | 550.92 | ||
10 | ||||||||||||||||||
11 | MD | 128.84 | ||||||||||||||||
12 | VVT | 1,048.26 | ||||||||||||||||
13 | 125.00 | 25.00 | 100.00 | Bonus | 125.00 | SSP | 77.50 | |||||||||||
14 | MD | 18.13 | ||||||||||||||||
15 | VVT | 275.00 | ||||||||||||||||
16 | ||||||||||||||||||
17 | ||||||||||||||||||
18 | NC | Nanny and Cory | Temp | John Doe | 12515 | 133.00 | 57.00 | 76.00 | 173.33 | Regular Salary | 133.00 | 173.33 | 33P | 1,733.34 | SSP | 810.94 | ||
19 | Apple | 19.00 | MD | 189.65 | ||||||||||||||
20 | BUS | 120.00 | CT/ NY | 436.56 | ||||||||||||||
21 | Eyes | 8.22 | FAM | 10.00 | ||||||||||||||
22 | YSD | 2.60 | ||||||||||||||||
23 | ||||||||||||||||||
Raw (2) |
Thank you for all your Help in advance