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.

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.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,216,075
Messages
6,128,668
Members
449,463
Latest member
Jojomen56

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