MattMaxWarehouse
New Member
- Joined
- Oct 12, 2017
- Messages
- 4
I have a macros that auto inserts rows based on values. I have 30+ Sheets on one spreadsheet, and if I use what I have, I can't get the rows to insert where I need them. Sheet 1 is set to insert rows at "3:3", Sheet 2 at "4:4", but if I use the macro for Sheet 1 then Sheet 2 inserts the rows out of order do to the change in row number.
I don't know how to solve this, if there is a way.
Code:
Sub Test()
If Sheets("1").Range("U2") = "Julia" Then
Else
If Sheets("1").Range("D28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("D28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("D27").Value
End If
End If
If Sheets("1").Range("U2") = "Jeremy" Then
Else
If Sheets("1").Range("E28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("E28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("E27").Value
End If
End If
If Sheets("1").Range("U2") = "Ed" Then
Else
If Sheets("1").Range("F28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("F28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("F27").Value
End If
End If
If Sheets("1").Range("U2") = "Lois" Then
Else
If Sheets("1").Range("G28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("G28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("G27").Value
End If
End If
If Sheets("1").Range("U2") = "Dennis" Then
Else
If Sheets("1").Range("H28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("H28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("H27").Value
End If
End If
If Sheets("1").Range("U2") = "Kanani" Then
Else
If Sheets("1").Range("I28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("I28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("I27").Value
End If
End If
If Sheets("1").Range("U2") = "Terri" Then
Else
If Sheets("1").Range("J28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("J28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("J27").Value
End If
End If
If Sheets("1").Range("U2") = "Phil" Then
Else
If Sheets("1").Range("K28").Value > 0 Then
Sheets("Month").Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Month").Range("I3").Value = Sheets("1").Range("K28").Value
Sheets("Month").Range("X3").Value = Sheets("1").Range("K27").Value
End If
End If
End Sub
I don't know how to solve this, if there is a way.