Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with macro

Status
Not open for further replies.

wafs

Technical User
Jan 17, 2006
112
US
Below is a code I created to look for a part number then I need it to put an X under each column heading where the part has been scanned. Right now this code puts an X under all column headings, I just need it to put under certain column headings. Any suggestions?

Part Number LotNumber WSH TP ROLL HT Ship
11588715 1428 X X

This is the data it will retreive from
LotNumber PartNumber Quantity FromProcess ToProcess
1428 11588715 1316 h TP
1428 11588715 1520 Headers ROLL



Sheets("data").Select
Range("A1:A400").AdvancedFilter xlFilterInPlace, CriteriaRange:=Range("A1:A400"), Unique:=True
Columns("A:A").Select
Selection.Copy
Sheets("Main Page").Select
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("data").ShowAllData
Do
Set myrange = Sheets(sh).Range(TestRange3)
'Set rsearch = Sheets(destsh).Range(output(13))
'If myrange = rsearch Then
p = p + 1
m = p + 1
vRet = Application.WorksheetFunction.VLookup(myrange, Worksheets("data").Range("A2:G300"), 2, False)
reportlocation = "A" + m 'partnumber
Sheets(destsh).Range(reportlocation) = vRet
If UCase(Trim(Sheets(sh).Range(TestRange))) = UCase(Trim(Sheets(destsh).Range(output(13)))) Then 'WSH
reportlocation = "C" + m 'X WSH
Sheets(destsh).Range(reportlocation) = strvar1
ElseIf UCase(Trim(Sheets(sh).Range(TestRange))) = UCase(Trim(Sheets(destsh).Range(output(5)))) Then 'ROLL
reportlocation = "E" + m 'X ROLL
Sheets(destsh).Range(reportlocation) = strvar1
ElseIf UCase(Trim(Sheets(sh).Range(TestRange))) = UCase(Trim(Sheets(destsh).Range(output(9)))) Then 't/p
reportlocation = "D" + m 'X TP
Sheets(destsh).Range(reportlocation) = strvar1
ElseIf UCase(Trim(Sheets(sh).Range(TestRange))) = UCase(Trim(Sheets(destsh).Range(output(7)))) Then 'HT
reportlocation = "F" + m 'X HT
Sheets(destsh).Range(reportlocation) = strvar1
ElseIf UCase(Trim(Sheets(sh).Range(TestRange))) = UCase(Trim(Sheets(destsh).Range(output(11)))) Then 'Ship
reportlocation = "G" + m 'X SHIP
Sheets(destsh).Range(reportlocation) = strvar1
End If
' End If
n = n + 1
TestRange3 = "A" + n
TestRange = "E" + n
output(1) = "A" + n
output(13) = "B" + n
Loop Until Sheets(destsh).Range(output(13)) =
 
You might get a better response in the Excel forum. This forum is for Visual Basic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top