Adding lines formula?

excelNewbie22

New Member
Joined
Aug 4, 2021
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
How to Add a certain line after each existing line with numbering?
like let's say this is the lines:

6, 7, 8, 9, 10, 11
12, 13, 14, 15, 16, 17
18, 19, 20, 21, 22, 23

and i want to add after each line the next phrase with a number, like this:
6, 7, 8, 9, 10, 11
New line (#1);
12, 13, 14, 15, 16, 17
New line (#2);
18, 19, 20, 21, 22, 23
New line (#3);

and so on...
can it be done in excel?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,983
Office Version
  1. 365
Platform
  1. Windows
You are welcome!

Note that I re-marked the first reply as the solution, as that has most of the "nuts and bolts" of the code needed (so if anyone in the future was looking for how to do this, that post would be the most helpful). My second post was just a small amendment to the original code.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

excelNewbie22

New Member
Joined
Aug 4, 2021
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
follow up question, apparentlyi forgot something
is there similar way to add a new cell before the first one which will contain
int[] arr1 = {

cause right now i have all one's=1's

int[] arr1 = {1, 2, 3, 4};
listArr.add(arr1);
int[] arr1 = {5, 6, 7, 8,};
listArr.add(arr2);

and i need to incremental all by 1
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,983
Office Version
  1. 365
Platform
  1. Windows
follow up question, apparentlyi forgot something
is there similar way to add a new cell before the first one which will contain
int[] arr1 = {

cause right now i have all one's=1's

int[] arr1 = {1, 2, 3, 4};
listArr.add(arr1);
int[] arr1 = {5, 6, 7, 8,};
listArr.add(arr2);

and i need to incremental all by 1
I am a little confused by your post, since you are referencing arrays, and we are not using arrays in the code in this thread anywhere.

If you want to simply want to insert the first row above the first entry, see if this does what you want:
VBA Code:
Sub MyInsertRows()

    Dim lr As Long
    Dim i As Long
    Dim ctr As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through data
    For i = 0 To lr
        ctr = ctr + 1
        Rows(i * 2 + 1).Insert
        Cells(i * 2 + 1, "A") = "New line (#" & ctr & ");"
    Next i
    
    Application.ScreenUpdating = True
    
End Sub
 

excelNewbie22

New Member
Joined
Aug 4, 2021
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
a friend is doing me a favor in java, since i don't know any code,
so when he stuck with numbering with the above problem he asked me to do it
then give him back the complete file

but i'm asking help from you guys/girls just to know if it was possible to do in excel
(tried googling it, try replace in word and notepad++ and nothing)

for the matter in hand, i need to be able to add a cell in the same line as the numbers and before them
with incremental them by 1, as shown in the example below

before:
1464.xlsx
ABCDEF
1123456
2789101112
גיליון1

after:
1464.xlsx
ABCDEFG
1123456
2int[] arr1 = {123456
3789101112
4int[] arr2 = {789101112
גיליון1
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,983
Office Version
  1. 365
Platform
  1. Windows
a friend is doing me a favor in java, since i don't know any code,
so when he stuck with numbering with the above problem he asked me to do it
then give him back the complete file

but i'm asking help from you guys/girls just to know if it was possible to do in excel
(tried googling it, try replace in word and notepad++ and nothing)

for the matter in hand, i need to be able to add a cell in the same line as the numbers and before them
with incremental them by 1, as shown in the example below

before:
1464.xlsx
ABCDEF
1123456
2789101112
גיליון1

after:
1464.xlsx
ABCDEFG
1123456
2int[] arr1 = {123456
3789101112
4int[] arr2 = {789101112
גיליון1
That appears to be quite different than your original question.
So you should post it to a new thread, so it appears as a new, unanswered question, and others will see it too.
 

excelNewbie22

New Member
Joined
Aug 4, 2021
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
you are right,
but now i got help with a script in notepad++ and problem solved
next time i'll probaly open a new thread
thanks!
 

Forum statistics

Threads
1,141,281
Messages
5,705,474
Members
421,397
Latest member
JBenn911

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
Top