FelixExcel
New Member
- Joined
- Sep 14, 2022
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
Hey all. Right now I have a command button, which inserts a row at a specific place. In the first cell of the inserted row a text is displayed and at the front of the text a number, which is set by how often the commandbutton has been pressed before. So, the first inserted row will say 1 "Text" in the first cell of that row and the second inserted row will say 2 "Text" in the first cell of that row and so on.
Private Sub CommandButton1_Click()
Sheets("Tabelle1").Range("A17").Select
ActiveCell.EntireRow.Insert Shift:=x1Down
Sheets("Tabelle1").Range("A17").Select
ActiveCell.Value = counter & ". Nachtrag"
The problem I have with this is that because the Rows always get inserted at a fixed place (A17) and shift the other rows down the newest added row is always on top, like this:
3. Text
2. Text
1. Text
Instead I would like them to be like this:
1. Text
2. Text
3. Text
Therefore I want to tell vba that depending on how often the commandbutton has been pressed before the row gets inserted at A17+ Counter. So for example if 2 rows have been added before, the new row will not be inserted at A17 but at A17+2 so A19.
I would appreciate any help.
Private Sub CommandButton1_Click()
Sheets("Tabelle1").Range("A17").Select
ActiveCell.EntireRow.Insert Shift:=x1Down
Sheets("Tabelle1").Range("A17").Select
ActiveCell.Value = counter & ". Nachtrag"
The problem I have with this is that because the Rows always get inserted at a fixed place (A17) and shift the other rows down the newest added row is always on top, like this:
3. Text
2. Text
1. Text
Instead I would like them to be like this:
1. Text
2. Text
3. Text
Therefore I want to tell vba that depending on how often the commandbutton has been pressed before the row gets inserted at A17+ Counter. So for example if 2 rows have been added before, the new row will not be inserted at A17 but at A17+2 so A19.
I would appreciate any help.