Copy & Paste a range of data 500 times with change in one line of data for each count

tatsujin90

New Member
Joined
May 23, 2018
Messages
3
Hello So i have have this code that i need to mutilply by 500 and change the "tab=number" in each line to next higher number for example :

this counts as one line >>> 500 of thoese
{
"Command": "click",
"Target": "id=mailType",
"Value": ""
},
{
"Command": "select",
"Target": "id=mailType",
"Value": "label=Reorder #2"
},
{
"Command": "click",
"Target": "css=#mailForm > input:nth-child(4)",
"Value": ""
},
{
"Command": "selectWindow",
"Target": "tab=1",
"Value": ""
},

two

{
"Command": "click",
"Target": "id=mailType",
"Value": ""
},
{
"Command": "select",
"Target": "id=mailType",
"Value": "label=Reorder #2"
},
{
"Command": "click",
"Target": "css=#mailForm > input:nth-child(4)",
"Value": ""
},
{
"Command": "selectWindow",
"Target": "tab=2",
"Value": ""
},


three

{
"Command": "click",
"Target": "id=mailType",
"Value": ""
},
{
"Command": "select",
"Target": "id=mailType",
"Value": "label=Reorder #2"
},
{
"Command": "click",
"Target": "css=#mailForm > input:nth-child(4)",
"Value": ""
},
{
"Command": "selectWindow",
"Target": "tab=3",
"Value": ""
},


four


{
"Command": "click",
"Target": "id=mailType",
"Value": ""
},
{
"Command": "select",
"Target": "id=mailType",
"Value": "label=Reorder #2"
},
{
"Command": "click",
"Target": "css=#mailForm > input:nth-child(4)",
"Value": ""
},
{
"Command": "selectWindow",
"Target": "tab=4",
"Value": ""
},

<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>


and so on 500 time with the "tab=number is ranging from 1-500"


THanks for reading this and helping )) God bless.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
this is what for loops are ... for :)

Code:
Dim i As Integer
Dim html As String
html = [COLOR=#0000ff]"..."[/COLOR]
For i = 1 To 500
    html = html & vbCrLf & [COLOR=#0000ff]"..."[/COLOR] & i & [COLOR=#0000ff]"..."[/COLOR]
Next i

(placeholders for you to update)

that code would keep appending a string value to the html string 500 times (each time on a new line... vbCrLf = carriage return, line feed) ... so modify it to print your desired string and concatenate the i integer into the string which will count 1 to 500
 
Last edited:
Upvote 0
stop being such a noob then :) the answer is here, you just have to substitute. I suggest googling what is confusing or simply asking here.

Code:
Dim i As Integer
Dim html As String
html = "" [COLOR=#008000]'i just looked at your code.... you dont need this part since the whole thing repeats and only the number changes... you can start with empty string[/COLOR]
For i = 1 To 500
    html = html & vbCrLf & "(the part that repeats before the number)" & i & "(the part that repeats after the number)"
Next i

vbCrLf is a new line... google "concatenation in vba"
 
Last edited:
Upvote 0
Really didn't understand what to do will try to finish it manually as need to finish the job asap, and will try to google "concatenation in vba" around and ask in reddit also
 
Upvote 0
if you have variables with strings in them... you can combine them... it is called concatenation

Code:
Dim a As String, b As String, i As Long

a = "(bunch of code)" [COLOR=#008000]'substitute the part of your code before the number[/COLOR]
b = "(more code)" [COLOR=#008000]'substitute the part of your code after the number[/COLOR]
i = 2

MsgBox a & i & b

[COLOR=#008000]'prints (bunch of code)2(more code)[/COLOR]

im not going to do the tedious work of doing it for you and dont expect people to do that
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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
Back
Top