YellowLabPro
05-23-2007, 06:56 AM
In my loop I would like to place an If statment that will utilize an Array.
I do something similar w/ a formula in Excel, but this is new to me by way of placing it inside of code.
Reference formula in Excel: =IF(OR(ISNUMBER(MATCH(AD5,{"SURF","SKATE","SNOW","WAKE"})))
If any values match these terms, Surf, Skate, Snow, Wake are in column E, then instead of using this line: .Cells(LRowt, "J").Value = Wss.Cells(i, "E").Value ' Item
use this line: .Cells(LRowt, "J").Value = Wss.Cells(i, "F").Value ' Item or use an offset of 1 column
Existing Loop:
For i = 2 To Wss.Cells(Rows.Count, "I").End(xlUp).Row
LRowt = Wst.Cells(Rows.Count, "I").End(xlUp).Row + 1
If Val(Cells(i, "j")) > 0 Then
With Wst
.Cells(LRowt, "AC").Value = Wss.Cells(i, "j").Value ' Qty = col. AC/29
.Cells(LRowt, "H").Value = Wss.Cells(i, "A").Value ' Company
.Cells(LRowt, "I").Value = Wss.Cells(i, "C").Value ' Item Name
.Cells(LRowt, "M").Value = Wss.Cells(i, "D").Value ' Color
.Cells(LRowt, "J").Value = Wss.Cells(i, "E").Value ' Item
.Cells(LRowt, "Z").Value = Wss.Cells(i, "G").Value ' Cost
.Cells(LRowt, "N").Value = Wss.Cells(i, "H").Value ' Size
End With
End If
Next i
Thanks for looking over,
Doug
I do something similar w/ a formula in Excel, but this is new to me by way of placing it inside of code.
Reference formula in Excel: =IF(OR(ISNUMBER(MATCH(AD5,{"SURF","SKATE","SNOW","WAKE"})))
If any values match these terms, Surf, Skate, Snow, Wake are in column E, then instead of using this line: .Cells(LRowt, "J").Value = Wss.Cells(i, "E").Value ' Item
use this line: .Cells(LRowt, "J").Value = Wss.Cells(i, "F").Value ' Item or use an offset of 1 column
Existing Loop:
For i = 2 To Wss.Cells(Rows.Count, "I").End(xlUp).Row
LRowt = Wst.Cells(Rows.Count, "I").End(xlUp).Row + 1
If Val(Cells(i, "j")) > 0 Then
With Wst
.Cells(LRowt, "AC").Value = Wss.Cells(i, "j").Value ' Qty = col. AC/29
.Cells(LRowt, "H").Value = Wss.Cells(i, "A").Value ' Company
.Cells(LRowt, "I").Value = Wss.Cells(i, "C").Value ' Item Name
.Cells(LRowt, "M").Value = Wss.Cells(i, "D").Value ' Color
.Cells(LRowt, "J").Value = Wss.Cells(i, "E").Value ' Item
.Cells(LRowt, "Z").Value = Wss.Cells(i, "G").Value ' Cost
.Cells(LRowt, "N").Value = Wss.Cells(i, "H").Value ' Size
End With
End If
Next i
Thanks for looking over,
Doug