Here is a code that I created and I need it to run through the entire code before it loops. I need the code to look at all the ID numbers before it increments and loops. Any suggestions?
Sub copyinfo_to_main_page()
'
' copyinfo Macro
' Macro recorded 4/7/2006 by Wendy Smith
'
Dim Cellstart As Integer
Dim p As Integer
Dim x As Integer
Dim n As String 'counting variable
Dim m As String
Dim TestRange As String 'to process
Dim TestRange2 As String 'part number
Dim TestRange3 As String 'id number
Dim sh As String 'source sheet
Dim destsh As String 'destination sheet
Dim reportlocation As String
Dim output(1 To 14) As String
Dim strvar1 As String
Dim vRet As Variant
Dim myrange As Range
Dim rsearch As Range
Cellstart = 2 'starting point of source sheet
p = 0
strvar1 = "X"
sh = "data" 'work sheet where the part info is kept
destsh = "Main Page" 'work sheet where part info is broken out
'Clear out old Data and unhide rows
Sheets("Main Page").Select
Sheets(destsh).Range("A2:h400").Select
Selection.ClearContents
'Retreive data from source sheet
n = Cellstart
TestRange = "E" + n 'to process source sheet
TestRange2 = "B" + n 'part # source sheet
TestRange3 = "A" + n 'ID number source sheet
output(1) = "A" + n 'part number
output(2) = Sheets(destsh).Range(output(1)).Value
output(3) = "C1" 'WASH
output(4) = Sheets(destsh).Range(output(3)).Value
output(9) = "D1" 't/p
output(10) = Sheets(destsh).Range(output(9)).Value
output(5) = "E1" 'Roll
output(6) = Sheets(destsh).Range(output(5)).Value
output(7) = "F1" 'HT
output(8) = Sheets(destsh).Range(output(7)).Value
output(11) = "G1" 'ship
output(12) = Sheets(destsh).Range(output(11)).Value
output(13) = "B" + n 'ID Number
output(14) = Sheets(destsh).Range(output(13)).Value
'Output into destination sheet
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
reportlocation = "C" + m 'X WSH
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "E" + m 'X ROLL
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "D" + m 'X TP
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "F" + m 'X HT
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "G" + m 'X SHIP
Sheets(destsh).Range(reportlocation) = strvar1
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)) = ""
End Sub
Sub copyinfo_to_main_page()
'
' copyinfo Macro
' Macro recorded 4/7/2006 by Wendy Smith
'
Dim Cellstart As Integer
Dim p As Integer
Dim x As Integer
Dim n As String 'counting variable
Dim m As String
Dim TestRange As String 'to process
Dim TestRange2 As String 'part number
Dim TestRange3 As String 'id number
Dim sh As String 'source sheet
Dim destsh As String 'destination sheet
Dim reportlocation As String
Dim output(1 To 14) As String
Dim strvar1 As String
Dim vRet As Variant
Dim myrange As Range
Dim rsearch As Range
Cellstart = 2 'starting point of source sheet
p = 0
strvar1 = "X"
sh = "data" 'work sheet where the part info is kept
destsh = "Main Page" 'work sheet where part info is broken out
'Clear out old Data and unhide rows
Sheets("Main Page").Select
Sheets(destsh).Range("A2:h400").Select
Selection.ClearContents
'Retreive data from source sheet
n = Cellstart
TestRange = "E" + n 'to process source sheet
TestRange2 = "B" + n 'part # source sheet
TestRange3 = "A" + n 'ID number source sheet
output(1) = "A" + n 'part number
output(2) = Sheets(destsh).Range(output(1)).Value
output(3) = "C1" 'WASH
output(4) = Sheets(destsh).Range(output(3)).Value
output(9) = "D1" 't/p
output(10) = Sheets(destsh).Range(output(9)).Value
output(5) = "E1" 'Roll
output(6) = Sheets(destsh).Range(output(5)).Value
output(7) = "F1" 'HT
output(8) = Sheets(destsh).Range(output(7)).Value
output(11) = "G1" 'ship
output(12) = Sheets(destsh).Range(output(11)).Value
output(13) = "B" + n 'ID Number
output(14) = Sheets(destsh).Range(output(13)).Value
'Output into destination sheet
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
reportlocation = "C" + m 'X WSH
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "E" + m 'X ROLL
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "D" + m 'X TP
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "F" + m 'X HT
Sheets(destsh).Range(reportlocation) = strvar1
reportlocation = "G" + m 'X SHIP
Sheets(destsh).Range(reportlocation) = strvar1
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)) = ""
End Sub