Is it possible in Excel to use a number in one cell to make that many copies of data from another cell in a 3rd cell?

2

I'm trying to create a database/sitemap of sorts and need to be able to take data I already know and use it to make multiple copies of one cell, append something to what's in that cell based on a number in a different cell. Below is an example of data I have

26      example.com/search?find_loc=St.+John's+Newfoundland

What I need to do is take the URL and, based on the fact that we have 26 pages worth, create the 26 page URLs by appending to each except the first URL the page number as seen in the example below in a 3rd row.

Producing this:

example.com/search?find_loc=St.+John's+Newfoundland
example.com/search?find_loc=St.+John's+Newfoundland&start=10
example.com/search?find_loc=St.+John's+Newfoundland&start=20
example.com/search?find_loc=St.+John's+Newfoundland&start=30
example.com/search?find_loc=St.+John's+Newfoundland&start=40
example.com/search?find_loc=St.+John's+Newfoundland&start=50
example.com/search?find_loc=St.+John's+Newfoundland&start=60
example.com/search?find_loc=St.+John's+Newfoundland&start=70
example.com/search?find_loc=St.+John's+Newfoundland&start=80
example.com/search?find_loc=St.+John's+Newfoundland&start=90
example.com/search?find_loc=St.+John's+Newfoundland&start=100
example.com/search?find_loc=St.+John's+Newfoundland&start=110
example.com/search?find_loc=St.+John's+Newfoundland&start=120
example.com/search?find_loc=St.+John's+Newfoundland&start=130
example.com/search?find_loc=St.+John's+Newfoundland&start=140
example.com/search?find_loc=St.+John's+Newfoundland&start=150
example.com/search?find_loc=St.+John's+Newfoundland&start=160
example.com/search?find_loc=St.+John's+Newfoundland&start=170
example.com/search?find_loc=St.+John's+Newfoundland&start=180
example.com/search?find_loc=St.+John's+Newfoundland&start=190
example.com/search?find_loc=St.+John's+Newfoundland&start=200
example.com/search?find_loc=St.+John's+Newfoundland&start=210
example.com/search?find_loc=St.+John's+Newfoundland&start=220
example.com/search?find_loc=St.+John's+Newfoundland&start=230
example.com/search?find_loc=St.+John's+Newfoundland&start=240
example.com/search?find_loc=St.+John's+Newfoundland&start=250

Lope

Posted 2017-03-07T20:38:03.733

Reputation: 21

What have you tried? You can do something like `=hyperlink("http://www.example.com/search?find_loc=St.+John%27s+Newfoundland&start=%22&row()*10") to get started, no?

– BruceWayne – 2017-03-07T20:46:29.177

havent really tried anything yet because im 100% stumped where to even start.. my problem is that its not just one url i need to do it to but rather 65,000+ – Lope – 2017-03-07T20:47:53.190

If current row is less than or equal to the magic integer (26 in your example), then hyperlink "base url" & "current row * 10", else show nothing. Then, fill down. – picobit – 2017-03-07T21:09:51.240

Answers

0

I'd likely concatenate in the number using the &. Consider this: A1= the beginning of the url (example.com/search?find_loc=St.+John's+Newfoundland&start=) B1 = end of the url ( example.com/search?) Starting in A2, list all the numbers you need (10, 20, 30, etc.. drag the little formula handle to copy them bad boys). With this set up you can use the following formula in B2 and drag the fill handle to copy it all the way down.

=$A$1 & A2 & $B$1

If you need a clickable hyperlink, wrap the B2 formula in a HYPERLINK before copying down.

=HYPERLINK($A$1 & A2 & $B$1)

BamAlmighty

Posted 2017-03-07T20:38:03.733

Reputation: 69

0

Code blocks help a bit for legibility.

example.com/search?find_loc=St.+John's+Newfoundland 
example.com/search?find_loc=St.+John's+Newfoundland&start=10

...

example.com/search?find_loc=St.+John's+Newfoundland&start=240 
example.com/search?find_loc=St.+John's+Newfoundland&start=250

I would use the =CONCATENATE() function.

In Cell A1, or whatever cell you are using, place:

example.com/search?find_loc=St.+John's+Newfoundland 

In cell B1:

&start=

And in column C, fill the column with the range 10..250. Then concatenate the rows in column D:

=CONCATENATE($A$1, $B$1, $C1)

Copy that formula down the column, and you should be able to display your data fairly easily.

smilingfrog

Posted 2017-03-07T20:38:03.733

Reputation: 121

the problem is this is still a heavy bit of hand work in the sense that i need to give it a range per url.. if it was 1 or 2 url's that needed work like this that would be fine but in my case its 65,000+. i need some way to use the number i have in column A (in this example 26) to tell excel to create a total of 26 url variations based on Column B and apend ( in this example &start= ) to 25 of them with numbers increasing by 10 from 2nd url on. and basically make a list in either a new spreadsheed or in column C. and that needs to be done to 65k+ with all different column A's – Lope – 2017-03-07T22:22:16.410

You could still do this in excel, but you may be better of writing a macro that loops through the list. Frankly, though, unless you need to have all the data in a spreadsheet, this might be something to do programmatically. If 26 is an average number, you are looking at ~1.7M entries. There are probably better methods to do this. – smilingfrog – 2017-03-07T23:46:24.643

0

I’ll assume that you have your counts in Column A and your base URLs in Column B, and you want your constructed URLs in Column D, all starting in Row 1.  This is fairly easy with “helper columns”.  I’ll use Columns G and H; you can use any two columns you want (e.g., Y and Z), and you can hide them once you get this working.

Enter the following:

  • G11
  • H10
  • G2=IF(G1<0, -1, IF(H1+1<INDEX(A:A, G1), G1, IF(INDEX(A:A, G1+1)="", -1, G1+1)))
  • H2=IF(G2<0, -1, IF(H1+1<INDEX(A:A, G1), H1+1, 0))
  • D1=IF(G1<0, "", INDEX(B:B, G1) & IF(H1>0, "&start=" & H1*10, ""))

Select cells G2 and H2 and drag/fill down.  Select cell D1 and drag/fill down.

spreadsheet

This will treat a 0 in Column A as if it were a 1.

Scott

Posted 2017-03-07T20:38:03.733

Reputation: 17 653

0

Here's an implementation of the approach in my comment to your question. Cell A2 contains the base prefix that's common to all of the URLs that you want to generate. Cells B2, B3, B4,... are the locations that you want to generate. C2, C3, C4,... are the number of strings to generate for each location.

Each location will be generated in its own column. The formula in E1 is:

=IF(ROW()=1,$A$2&$B$2,IF(ROW()<=$C$2,$A$2&$B$2&"&start="&(ROW()-1)*10,""))

E2:

=IF(ROW()=1,$A$2&$B$3,IF(ROW()<=$C$3,$A$2&$B$3&"&start="&(ROW()-1)*10,""))

E3:

=IF(ROW()=1,$A$2&$B$4,IF(ROW()<=$C$4,$A$2&$B$4&"&start="&(ROW()-1)*10,""))

The "B" and "C" cells are moving down by one each time. Continue the pattern as you move to the right, and then fill the formulas down.

If you have hundreds of locations and don't want to edit each formula, then let me know. The whole thing can be done with a single formula, but it will require the use of INDIRECT() which I try to stay away from. It's one of the volatile functions so must be used judiciously.

enter image description here

picobit

Posted 2017-03-07T20:38:03.733

Reputation: 211

(1) I believe that you have a typo: what you present as E1, E2, and E3 should be E1, F1, and G1. (2) The OP says that the file has over 50,000 URLs.  If that’s true, then Excel might not be the best tool for this job.  But what if it’s only a few hundred?  If I understand your answer correctly, it would require the user to enter those formulas manually in E1, F1, G1,H1, I1, J1 …, since they cannot be filled to the right. That would be a lot of work, and very error-prone. (3) Why do you assume that all the URLs begin with example.com/search?find_loc=? – Scott – 2017-03-10T00:14:31.710