Link to home
Start Free TrialLog in
Avatar of Master Work
Master Work

asked on

I need to insert after every single raw the value from the third column like the sheet1 attached.

I need to insert after every single raw the value from the third column like the sheet1 attached.

Regards,

Dallag
insert_every_sngle_raw.xlsx
Avatar of als315
als315
Flag of Russian Federation image

Would you show source and result on separate sheets?
Please try this...

Sub InsertRow()
Dim wsData As Worksheet
Dim lr As Long, i As Long
Application.ScreenUpdating = False
Set wsData = Worksheets("Sheet1")
lr = wsData.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
    wsData.Rows(i).Insert
    wsData.Cells(i, 1).Value = wsData.Cells(i + 1, 1) & wsData.Cells(i + 1, 4)
Next i
Application.ScreenUpdating = True
End Sub

Open in new window

Click the button called "Insert Rows" on Sheet1 to run the code.
insert_every_sngle_raw.xlsm
insert after every single raw the value from the third column
In your sample row s are inserted before rows. Is it correct?
"ps " and value from column D should be inserted?
Please replace line#10 with the following line...

wsData.Cells(i, 1).Value = "ps" & wsData.Cells(i + 1, 4)

Open in new window

insert_every_sngle_raw.xlsm
Avatar of Master Work
Master Work

ASKER

can I have the result in a different sheet?
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial