Concatenating multiple rows and columns

RyanUK

New Member
Joined
Dec 17, 2010
Messages
5
Hi everyone,

I'm looking to manually create a sitemap using Excel VBA.

In column A I have a list of all the urls (around 200,000) but there could be an unlimited amount, in column B I have a priority list of 0.0 to 1.0 and column C has a last modified date/time.

Between these cell values there is XML markup

http://i56.tinypic.com/2hhdcoi.jpg - Example of input
http://i52.tinypic.com/10qvrtl.jpg - Example of output

So far I have been able to add the first two values together but is there a better way of doing this without using 3 loops?

Also sometimes a lastmod time is not always present so the contents of the xml markup should not be visible.

The xml code needs to sit on new lines as shown in the example output so do you know if there is a way to force each of the blocks of data onto a new line?

Code:
Sub createSitemap()
Dim siteUrl As Variant
Dim siteUrlPriority As Variant
Range("D1").Select
For Each siteUrl In Range("B1:B2")
    For Each siteUrlPriority In Range("A1:A5")
        ActiveCell.Formula = siteUrl & " " & siteUrlPriority
        ActiveCell.Offset(1, 0).Select
    Next
Next
Range("D1").Select
End Sub
Many thanks in advance.

Ryan
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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