Option Explicit
Sub testme()
Dim myCol1 As Range
Dim myCol2 As Range
Dim myCol3 As Range
Dim myCell1 As Range
Dim myCell2 As Range
Dim myCell3 As Range
Dim wks As Worksheet
Dim newWks As Worksheet
Dim oRow As Long
Dim keyName As String
Dim i As Long
Set wks = Worksheets("Start->")
With wks
Set myCol1 = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
Set myCol2 = .Range("c1", .Cells(.Rows.Count, "C").End(xlUp))
Set myCol3 = .Range("b1", .Cells(.Rows.Count, "B").End(xlUp))
If myCol1.Cells.Count * myCol2.Cells.Count > .Rows.Count Then
MsgBox "Too much data!"
Exit Sub
End If
End With
Set newWks = Worksheets.Add
oRow = 0
i = 0
For Each myCell1 In myCol1.Cells
i = i + 1
For Each myCell2 In myCol2.Cells
oRow = oRow + 1
With newWks.Cells(oRow, "A")
keyName = myCell1.Value
keyName = Replace(keyName, " ", "%20")
.Value = "rule"
.Offset(0, 1).Value = myCell1.Value & " ad=" & myCell2.Value
.Offset(0, 2).Value = "<datamatch name=""ck""><![CDATA[" & keyName & "]]></datamatch><datamatch name=""ad""><![CDATA[" & myCell2.Value & "]]></datamatch>"
.Offset(0, 3).Value = myCol3.Cells(i, 1)
End With
Next myCell2
Next myCell1
End Sub
Bookmarks