Insert Row and Highlight New Row 1 of 3 Different Colours.

Roj47

Board Regular
Joined
May 4, 2011
Messages
65
Office Version
  1. 365
Platform
  1. Windows
I have sourced the below code and removed the source name, do not know if I should do that but rather add back than outright cause an issue.

I cannot merge other code into this code as its clearly beyond my ability. I would like support/ help on how to update to achieve the function in the [] within the code please.

Sub Insert_x()
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "Ididntknowwhether tokeepsowentsafe"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Set WorkRng = WorkRng.Columns(1)
xLastRow = WorkRng.Rows.Count
Application.ScreenUpdating = False
For xRowIndex = xLastRow To 1 Step -1
Set Rng = WorkRng.Range("A" & xRowIndex)
If Rng.Value = "x" Then [Rather than insert a row if x=1, I would like it to be a range e.g. if x=1 to 3]
Rng.Offset(1, 0).EntireRow.Insert Shift:=xlDown
End If
Next
[I am trying to merge code to highlight the new cell one of 3 colours based on the range in the above query, x=1 to 3]
Application.ScreenUpdating = True
End Sub


If Excel gets itself into a world of confusion I would be ecstatic if it were one row inserted and one colour and I would just create a few macros titled with the needed number.

Thanks guys.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top