View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TheDPQ TheDPQ is offline
external usenet poster
 
Posts: 1
Default Macro Help. Looping, code change.


I need to get sheet 1 http://www.thedpq.com/excel_01.gif to look lik
sheet 2 http://www.thedpq.com/excel_02.gif

I basically have a list of keywords, ad ids, and urls. I need B to b
listed as many times as there are items in E. A,D,F,G are sort o
filler data that needs to be used to make it look like sheet 2.
http://www.thedpq.com/excel_02.gif

Someone gave me the following code which i don't know enough to chang
it to get it to what i need.

The code would be if A was a list of keywords and B was a list of a
IDs. Its doing half the work already.


Option Explicit
Sub testme()
Dim myCol1 As Range
Dim myCol2 As Range
Dim myCell1 As Range
Dim myCell2 As Range
Dim wks As Worksheet
Dim newWks As Worksheet
Dim oRow As Long

Set wks = Worksheets("Sheet1")

With wks
Set myCol1 = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
Set myCol2 = .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
For Each myCell1 In myCol1.Cells
For Each myCell2 In myCol2.Cells
oRow = oRow + 1
With newWks.Cells(oRow, "A")
.Value = myCell1.Value
.Offset(0, 1).Value = myCell2.Value
End With
Next myCell2
Next myCell1

End Sub



--
TheDP
-----------------------------------------------------------------------
TheDPQ's Profile: http://www.excelforum.com/member.php...fo&userid=3091
View this thread: http://www.excelforum.com/showthread.php?threadid=50642