LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default iterate through a row to find a match

hi there, i'm trying have a table that lists prices for different
products from many stores. so, i've already made a macro to find the
min price found for each product but i want to write a macro that will
by iterate through the product's row (from left to right) until it
finds the first price that matches what i found as my minimum price and
then give me the name of that store that offers the product at that
price. This is what I have so far...

Sub ConstructCheapestStoresTable()
Dim productRow As Integer
Dim productNumber As Integer
Dim ShopName As String
Dim StoreColumn As Integer
Dim rowoffset As Integer
Dim productName As String

productRow = productNumber + 1
rowoffset = numProducts + 7
productNumber = 1
numProducts = 11

Range(Cells(2, 1), Cells(numProducts + 1, 1)).Select
'Range("R2C1:RnumProducts + 1C1").Select
Selection.Copy
Range(Cells(rowoffset + 1, 1), Cells(rowoffset + numProducts,
1)).Select
'Range("R" & CStr(rowoffset + 1) & "C1" & ":R" & CStr(rowoffset +
numProducts) & "C2").Select
ActiveSheet.Paste

Do While Worksheets("Table").Cells(productRow, 1) < ""

If Worksheets("Table").Cells(productRow, StoreColumn) = _
Worksheets("Table").Cells(productRow, numSites + 2) Then

productName = Worksheets("Table").Cells(productRow, 1).Value
'added
ShopName = Worksheets("Table").Cells(1, StoreColumn).Value
'added

Worksheets("Table").Cells(rowoffset + 1, 2).Value = productName
'added
Worksheets("Table").Cells(rowoffset + 1, 1).Value = ShopName 'added

End If

productRow = productRow + 1 'added

Loop

Worksheets("Table").Cells(rowoffset, 1).Value = "Product"
Worksheets("Table").Cells(rowoffset, 2).Value = "Cheapest Store"

Worksheets("Table").Select
Range(Cells(rowoffset, 1), Cells(rowoffset + numProducts,
2)).Select
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub


i'm having trouble getting vba to read what's inside my do while loop.
everything else works except the getting the store name!!

any help would be greatly appreciated. thanks!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find the second match using the match function Ray Excel Worksheet Functions 1 April 6th 09 10:19 PM
Find an exact match and go to that match Heath Excel Discussion (Misc queries) 0 February 12th 09 02:28 AM
Find partial match from column A,B and fill partial match in C? Tacrier Excel Discussion (Misc queries) 4 October 24th 08 11:24 PM
Find Exact Match using INDEX, MATCH DoubleUU Excel Worksheet Functions 3 August 15th 08 02:42 PM
Can't iterate thru a row with For peter Excel Programming 2 January 7th 05 04:46 AM


All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"