deadlyjack
New Member
- Joined
- Aug 21, 2021
- Messages
- 23
- Office Version
- 365
- 2019
- Platform
- Windows
I've got a little task where I need to merge 2 rows together IF the value is greater than 11.
I got the first code to work, but this is only for a specific row...
What I need to generate is a dynamic Loop throughout, x = 3 To 33.
In this case I3 is greater than 11, so if this is the case, then I need to jump I4 and continue my loop on I5.
There's probably an easier code for this that won't crash My excel-file, so please, if you have an answer that may reduce useage of RAM, show me an alternative ?
In other words:
By the way, I'd also need to repeat this process IF I3 greater than 22. Then I'd need to merge 4 rows together in the same way, instead of two rows.
I got the first code to work, but this is only for a specific row...
What I need to generate is a dynamic Loop throughout, x = 3 To 33.
In this case I3 is greater than 11, so if this is the case, then I need to jump I4 and continue my loop on I5.
There's probably an easier code for this that won't crash My excel-file, so please, if you have an answer that may reduce useage of RAM, show me an alternative ?
In other words:
VBA Code:
If Produktionshall.Cells(x, "I") <= 11 Then
Range("A4:P4").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range( _
"B3:B4,C3:C4,D3:D4,E3:E4,F3:F4,G3:G4,H3:H4,I3:I4,J3:J4,K3:K4,L3:L4,M3:M4,O3:O4,P3:P4" _
).Select
Range("P3").Activate
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Range("A3").Select
Selection.Copy
Range("A4").Select
ActiveSheet.Paste
Exit Function
End If
VBA Code:
Sub DrumCount()
myVar = CheckDrums
End Sub
By the way, I'd also need to repeat this process IF I3 greater than 22. Then I'd need to merge 4 rows together in the same way, instead of two rows.