0

I want to make array of cells in excel to using VBA to add new row, I used this code

Private Sub add_Click()
Sheets("Block B").Range("C8").Select
ActiveCell.EntireRow.Insert Shift:=xlDown Sheets("Block B").Range("C8:L8").Select  Selection.Borders.Weight = xlThin

But the new line insert in exact raw 8, I want in each click to add a new row in the next row 8, 9, 10, ...

How can I do it ?

2
  • Repeat it for the other two but do it in the order of 10, then 9, then 8 Commented Sep 29, 2018 at 20:04
  • You want to click a button and insert a new row at a specific row, and for each subsequent click to move down and insert a new row at the next row. View this SO question Commented Sep 30, 2018 at 0:06

1 Answer 1

0

We must turn the circulation from a lot to a small one.

Try this

Sub test()

    Dim Ws As Worksheet
    Dim i As Long

    Set Ws = Sheets("Block B")
    With Ws
        For i = 10 To 8 Step -1
            .Range("c" & i).EntireRow.Insert
            .Range("c" & i).Resize(1, 10).Borders.Weight = xlThin
        Next
    End With
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.