I am trying to write a code that will insert a row below the middle of my data.
I used a variable (count0) to hold the number of rows in the worksheet because I will have a different number of rows sometimes. count2 divides it by 2 to get the middle of my data. & then count1 adds 1 to the middle because the EntireRow.Insert function inserts above the row (so inserting above the row before the middle is the same as inserting below the middle).
Here's what I have:
Dim ws As Excel.Worksheet
Set ws = Worksheets("Insert Data")
Dim count0 As Long
Dim count1 As Long
Dim count2 As Long
count0 = Worksheets("Insert Data").Range("A:A").Rows.count
count2 = count0 / 2
count1 = count2 + 1
ws.Range("A" & count1).EntireRow.Insert`
Everything compiles but a row doesn't get inserted anywhere in my data let alone underneath the middle row. Any suggestions on how to fix this or a different way of going about it?