Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro Help. Looping, code change.
Wow ok i figured out more of that then i thought. I cheated and had lot of the stuff hard coded in the loop since it won't change. I jus need to be able to bring the URL into the loop. Updated post -- TheDP ----------------------------------------------------------------------- TheDPQ's Profile: http://www.excelforum.com/member.php...fo&userid=3091 View this thread: http://www.excelforum.com/showthread.php?threadid=50642 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change a specific code to generic in VB macro | Excel Discussion (Misc queries) | |||
Macro code to change tab name | Excel Programming | |||
Looping code in Excel macro | Excel Programming | |||
Can You Change A CommandButton Code Using A Macro? | Excel Programming | |||
Code looping when it should not | Excel Programming |