Paste and fill down increasing 2 numbers

Crocdundee

Board Regular
Joined
May 10, 2010
Messages
174
Office Version
  1. 2013
Platform
  1. Windows
Hoping I can get help here please

Purpose:
(1) paste from Clipboard in first empty cell in column 1
(2) ask for No of rows. (to be filled down)
(3) fill down increasing 2 numbers by 1
(4) go to next empty cell in column 1

Sample Output:
Paste from clipboard

race-1-6038007

How Many Rows? = 6

race-1-6038007
race-2-6038008
race-3-6038009
race-4-6038010
race-5-6038011
race-6-6038012
finally go to next empty cell
Regards Graham
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
try this on a copy of you data.

Also, your string must have 2 Dashes ("-") in it.

VBA Code:
Sub Do_it()

n = InputBox("How many Rows")
If Not IsNumeric(n) Then
    MsgBox "entry is not a number"
    Exit Sub
End If


sr = Range("A" & Rows.Count).End(xlUp).Row + 1
Cells(sr, "A").Select

ActiveSheet.Paste
x = ActiveCell.Value

For r = 1 To n - 1
    Cells(r + sr, "A") = "race-" & Split(x, "-")(1) + r & "-" & Split(x, "-")(2) + r
Next r

Cells(Range("A" & Rows.Count).End(xlUp).Row + 1, "A").Select

End Sub

hth,
Ross
 
Upvote 0
Solution
try this on a copy of you data.

Also, your string must have 2 Dashes ("-") in it.

VBA Code:
Sub Do_it()

n = InputBox("How many Rows")
If Not IsNumeric(n) Then
    MsgBox "entry is not a number"
    Exit Sub
End If


sr = Range("A" & Rows.Count).End(xlUp).Row + 1
Cells(sr, "A").Select

ActiveSheet.Paste
x = ActiveCell.Value

For r = 1 To n - 1
    Cells(r + sr, "A") = "race-" & Split(x, "-")(1) + r & "-" & Split(x, "-")(2) + r
Next r

Cells(Range("A" & Rows.Count).End(xlUp).Row + 1, "A").Select

End Sub

hth,
Ross
Ross Works fine and I appreciate your help, "However", ( I bet you would know this is coming ).
Changes if you don't mind ne asking is
In B1 Paste Clipboard
example: https://www.sportsbet.com.au/greyhound-racing/australia-nz/the-meadows/race-1-6038007
extract to empty cell in col A Race*.*
Please note Race*.* is not always same length, so i guess extract right of the 4th "/"
then in the current cell put double quotes around the extracted text and your code can follow
clear cell1 in B column
I styffed up by not expecting the extraction would be easy for me
Regards Graham
 
Upvote 0
Ross Works fine and I appreciate your help, "However", ( I bet you would know this is coming ).
Changes if you don't mind ne asking is
In B1 Paste Clipboard
example: https://www.sportsbet.com.au/greyhound-racing/australia-nz/the-meadows/race-1-6038007
extract to empty cell in col A Race*.*
Please note Race*.* is not always same length, so i guess extract right of the 4th "/"
then in the current cell put double quotes around the extracted text and your code can follow
clear cell1 in B column
I styffed up by not expecting the extraction would be easy for me
Regards Graham
Ok, Good News, I found the extraction formula with TRying again and again and all is good with this Code
Thank you again Ross
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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