Jul 12 2024 09:54 AM
I am having problems figuring out how to code the following. Once the column ‘Status’ is marked “DONE” need to move the row up above a merged row and put it in numerical order based off ‘Workorder Number’ and keep the conditional formatting that is applied and remove the marching ants from the row that was cut.
Jul 12 2024 10:59 AM
Your screenshot doesn't provide enough detail. Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?
Jul 12 2024 01:35 PM
I get "Access Denied".
Jul 12 2024 01:38 PM
Jul 12 2024 01:43 PM
Jul 12 2024 01:46 PM
Thanks, that works. I will take a look.
Jul 12 2024 01:58 PM
SolutionRight-click the sheet tab.
Select 'View Code' from the context menu.
Copy the code listed below into the worksheet module,
Switch back to Excel.
Save the workbook as a macro-enabled workbook (*.xlsm).
Make sure that you allow macros when you open it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim cel As Range
Dim trg As Range
Set rng = Intersect(Range("D18:D30"), Target)
If Not rng Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each cel In rng
If cel.Value = "DONE" Then
Set trg = Range("A18").End(xlUp)
If trg.Row = 1 Then
MsgBox "No more room!", vbExclamation
Exit For
End If
cel.EntireRow.Copy Destination:=trg.Offset(1)
cel.EntireRow.Delete
Range("A1").CurrentRegion.Sort Key1:=Range("C1"), Header:=xlYes
End If
Next cel
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
Jul 12 2024 02:02 PM
Jul 12 2024 02:58 PM
There is something strange going on there - if you look at Conditional Formatting > Manage Rules, you'll see that the rule is there. But it isn't applied.
After I used the Format Painter button to copy the formatting of one of the other rows, it started working again.
I don't have an explanation for this behavior...
Jul 12 2024 01:58 PM
SolutionRight-click the sheet tab.
Select 'View Code' from the context menu.
Copy the code listed below into the worksheet module,
Switch back to Excel.
Save the workbook as a macro-enabled workbook (*.xlsm).
Make sure that you allow macros when you open it.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim cel As Range
Dim trg As Range
Set rng = Intersect(Range("D18:D30"), Target)
If Not rng Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each cel In rng
If cel.Value = "DONE" Then
Set trg = Range("A18").End(xlUp)
If trg.Row = 1 Then
MsgBox "No more room!", vbExclamation
Exit For
End If
cel.EntireRow.Copy Destination:=trg.Offset(1)
cel.EntireRow.Delete
Range("A1").CurrentRegion.Sort Key1:=Range("C1"), Header:=xlYes
End If
Next cel
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub