search all sheets in book to find value and activate sheet with va
So if I understand you correctly you have a workbook with a whole pile of
sheets in it. You want to seach all of the sheets to find the sheet that has
the value you are looking for in E13? If so then...
sub Test()
call FindPOSheet("4533211/NICYC")
end
sub FindPOSheet(byval strToFind as string)
dim wks as worksheet
dim blnFound as boolean
blnfound = false
for each wks in worksheets
if wks.range("E13").value = strToFind then
blnfound = true
wks.select
exit for
endif
next wks
if blnfound = false then msgbox "No PO found"
set wks = nothing
End
--
HTH...
Jim Thomlinson
"Nigel" wrote:
Hi,
i have been really struggling with this macro. i have a PO Number.
example : 4533211/NICYC
in my po book i have up to 1000 purchase orders/ each with a unigue number.
i have set up a form and this number is set under a variable called PONumber
on every PO, the number is found in cell E13
what i need to do is this.
1.open my form and enter my PO number to find
2.press apply and the macro should take the number, and look through all of
the PO's until it finds the matching number.
3. when the number is found, stop searching and make this sheet active.
i have everything else completed ie errors etc, i just cannot get this right.
please can someone help me?
regs,
NS
ps i did post this in another area but feared that it might be missed;)
|