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
[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]{[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "select",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": "label=Reorder #2"[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "css=#mailForm > input:nth-child(4)",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "selectWindow",[/TD]
[/TR]
[TR]
[TD] "Target": "tab=1",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },

two

[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]{[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "select",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": "label=Reorder #2"[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "css=#mailForm > input:nth-child(4)",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "selectWindow",[/TD]
[/TR]
[TR]
[TD] "Target": "tab=2",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },


three

[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]{[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "select",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": "label=Reorder #2"[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "css=#mailForm > input:nth-child(4)",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "selectWindow",[/TD]
[/TR]
[TR]
[TD] "Target": "tab=3",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },


four


[TABLE="width: 64"]
<colgroup><col width="64" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]{[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "select",[/TD]
[/TR]
[TR]
[TD] "Target": "id=mailType",[/TD]
[/TR]
[TR]
[TD] "Value": "label=Reorder #2"[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "click",[/TD]
[/TR]
[TR]
[TD] "Target": "css=#mailForm > input:nth-child(4)",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
[TR]
[TD] {[/TD]
[/TR]
[TR]
[TD] "Command": "selectWindow",[/TD]
[/TR]
[TR]
[TD] "Target": "tab=4",[/TD]
[/TR]
[TR]
[TD] "Value": ""[/TD]
[/TR]
[TR]
[TD] },[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


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


THanks for reading this and helping )) God bless.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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