S
SangelNet
I have been looking for the correct way to use the following
For Each wsheet In ActiveWorkbook.Sheet(Sheet280, Sheet283,
Sheet284, Sheet285, Sheet286, Sheet287, Sheet288)
how can i use activeworkbook.worksheets and specify certain sheets in
the workbook.
the way i am using it is not giving errors but is not returning
anything. here is the full code :
Function vlookallsheets(Look_Value As Variant, Tble_Array As Range, _
Col_num As Integer, Optional Range_look As
Boolean)
'Use VLOOKUP to Look across ALL Worksheets and stops _
at the first match found.
'''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = False
Dim wSheet As Worksheet
Dim vFound
On Error Resume Next
For Each wSheet In ActiveWorkbook.Worksheet(Sheet280, Sheet283,
Sheet284, Sheet285, Sheet286, Sheet287, Sheet288)
With wSheet
Set Tble_Array = .Range(Tble_Array.Address)
vFound = WorksheetFunction.VLookup _
(Look_Value, Tble_Array, _
Col_num, Range_look)
End With
If Not IsEmpty(vFound) Then Exit For
Next wSheet
Set Tble_Array = Nothing
vlookallsheets = vFound
Application.ScreenUpdating = True
End Function
Thnx
For Each wsheet In ActiveWorkbook.Sheet(Sheet280, Sheet283,
Sheet284, Sheet285, Sheet286, Sheet287, Sheet288)
how can i use activeworkbook.worksheets and specify certain sheets in
the workbook.
the way i am using it is not giving errors but is not returning
anything. here is the full code :
Function vlookallsheets(Look_Value As Variant, Tble_Array As Range, _
Col_num As Integer, Optional Range_look As
Boolean)
'Use VLOOKUP to Look across ALL Worksheets and stops _
at the first match found.
'''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = False
Dim wSheet As Worksheet
Dim vFound
On Error Resume Next
For Each wSheet In ActiveWorkbook.Worksheet(Sheet280, Sheet283,
Sheet284, Sheet285, Sheet286, Sheet287, Sheet288)
With wSheet
Set Tble_Array = .Range(Tble_Array.Address)
vFound = WorksheetFunction.VLookup _
(Look_Value, Tble_Array, _
Col_num, Range_look)
End With
If Not IsEmpty(vFound) Then Exit For
Next wSheet
Set Tble_Array = Nothing
vlookallsheets = vFound
Application.ScreenUpdating = True
End Function
Thnx