DragonSoft
New Member
- Joined
- Oct 9, 2008
- Messages
- 21
(Note: I'm not allowed to install XL2BB on a company computer so pics will have to do)
Using the below code to put VLOOKUP in two columns (I & J) has stopped working. The formula IS put in each cell but the results is always #N/A even after verifying the look up value is in the table.
I am ONLY interested it the rows that have 936 in Column B (Dept.Resp)
Data Tab and Inspector Tab pictures attached
Using the below code to put VLOOKUP in two columns (I & J) has stopped working. The formula IS put in each cell but the results is always #N/A even after verifying the look up value is in the table.
I am ONLY interested it the rows that have 936 in Column B (Dept.Resp)
VBA Code:
Private Sub Auto_Open()
'Call Show_Screens(False)
Last_Row = 3 'skip the header rows
Set This_WorkSheet = Workbooks(ActiveWorkbook.Name).Worksheets("Data") ' Data Sheet
Last_Row = This_WorkSheet.Cells(This_WorkSheet.Rows.Count, "A").End(xlUp).Offset(0).Row
Sheets("Data").Select ' Select and Display the Data Sheet
Range("A2").Select ' Select the Active Cell
MyRange = "A3:J" & Last_Row ' Set our Sort Range
Range(MyRange).Select
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add(Range("G3:G" & Last_Row), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue.Color = RGB(255, 0 _
, 0)
ActiveWorkbook.Worksheets("Data").Sort.SortFields.Add Key:=Range("G3:G" & Last_Row), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Data").Sort
.SetRange Range("A2:J" & Last_Row)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For N = 3 To Last_Row
Worksheets("Data").Range("I" & N).Formula = "=VLOOKUP(C" & N & ", Inspectors!A3:F115,2,)"
'=VLOOKUP(A2,Inspectors!A3:F115,2,)
Worksheets("Data").Range("J" & N).Formula = "=VLOOKUP(C" & N & ", Inspectors!A3:F115,6,)"
Next N
Sheets("Data").Select ' Select and Display the NDT Sheet
Range("A3").Select ' Select the Active Cell
End Sub
Data Tab and Inspector Tab pictures attached
Attachments
Last edited by a moderator: