Hi there, I have been trawling the internet and am having great difficulty in finding an answer to my problem.
I have code that looks at 6 counts to find the maximum, and that works perfectly:
Maximum = (Application.WorksheetFunction.Max(Count1, Count2, Count3, Count4, Count5, Count6))
What I want to do with this maximum is insert that many rows into a different worksheet. I have the following code, however this does not work:
If Maximum > 5 Then
Rows("27:" & (Maximum - 5)).Select
Selection.Insert Shift:=xlDown
End If
(The "-5" is here as there are already 5 rows ready to be used)
For example, if my maximum was 38 it would insert rows between row 27 and row 38, it would not insert 38 rows. Also, if my maximum was 22 it would insert rows between row 22 and row 27, not insert 22 rows.
What do I need to change in order to make this work how it was intended?
Hope I have explained this clearly, TIA
I have code that looks at 6 counts to find the maximum, and that works perfectly:
Maximum = (Application.WorksheetFunction.Max(Count1, Count2, Count3, Count4, Count5, Count6))
What I want to do with this maximum is insert that many rows into a different worksheet. I have the following code, however this does not work:
If Maximum > 5 Then
Rows("27:" & (Maximum - 5)).Select
Selection.Insert Shift:=xlDown
End If
(The "-5" is here as there are already 5 rows ready to be used)
For example, if my maximum was 38 it would insert rows between row 27 and row 38, it would not insert 38 rows. Also, if my maximum was 22 it would insert rows between row 22 and row 27, not insert 22 rows.
What do I need to change in order to make this work how it was intended?
Hope I have explained this clearly, TIA

Last edited: