Hi guys,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I'm trying to write a macro that will loop through the values in Column F in wkbk1 (names of a product e.g. Plate) against the values in Row 6 in wkbk2( also names of a product e.g. Plate).<o></o>
<o> </o>
Once a match is found, copy this month’s price – found in wkbk2, row 16 for October, 17 for November etc..<o></o>
<o></o>
I know how to compare columns to columns, but columns to rows is causing a bit of difficulties. Here is my code:<o></o>
Any help is appreciated.
Thanks
<o></o>
I'm trying to write a macro that will loop through the values in Column F in wkbk1 (names of a product e.g. Plate) against the values in Row 6 in wkbk2( also names of a product e.g. Plate).<o></o>
<o> </o>
Once a match is found, copy this month’s price – found in wkbk2, row 16 for October, 17 for November etc..<o></o>
<o></o>
I know how to compare columns to columns, but columns to rows is causing a bit of difficulties. Here is my code:<o></o>
Code:
[FONT=Times New Roman][SIZE=3]Sub Update_Macro()[/SIZE][/FONT]
<o:p>[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Times New Roman] Dim sh1 As Worksheet[/FONT][/SIZE]
<o:p>[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Times New Roman] Set sh1 = Worksheets("Product List")[/FONT][/SIZE]
<o:p>[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Times New Roman] Set VolumeData = Workbooks.Open(Filename:="C:\Documents and Settings\vince\Desktop\workbook2.xls"). _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Worksheets("value data")[/FONT][/SIZE]
<o:p>[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]</o:p>
[SIZE=3][FONT=Times New Roman] lastrow1 = sh1.Cells(Rows.Count, "F").End(xlUp).Row[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] lastrow4 = VolumeData.Cells(6, Colls.Count).End(xlToLeft).Column[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] For i = 2 To lastrow1[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] For j = 2 To lastrow4[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]' If value in wkbk1 Column F is equal to wkbk 2 row 6 +[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] If sh1.Cells(i, "F").Value = VolumeData.Cells(6, j).Value Or _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] sh1.Cells(i, "A").Value = VolumeData.Cells(7, j).Value Then[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]' Copy Value[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] sh1.Cells(i, "M").Value = sh2.Cells(16, "B").Value[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Next j[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Next i[/FONT][/SIZE]
<o:p>[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]</o:p>
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]
Any help is appreciated.
Thanks