ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Jump to next sheet if not found (https://www.excelbanter.com/excel-programming/311666-jump-next-sheet-if-not-found.html)

Zurn[_8_]

Jump to next sheet if not found
 

Hello,


I'm trying to program a search the content of certain cells of tw
different sheets. When click on a button, program asks fo
RUN-nr...(=cellRun)
Then program has to search first in sheet one, when finding an empt
cell, the same search in sheet2. On the active cell, I run an othe
adjust program.


-Worksheets("sheet1").Activate
Range("C11:C12").Activate
Do While cellRun < ActiveCell
ActiveCell.Offset(rowOffset:=24).Activate
If IsEmpty(ActiveCell) Then
Exit Do
End If
Loop-

Now my problem: If I work with a DO LOOP in a Do Loop, the progra
isn't working.


several attempts didn't work...I'm not willing to give up trying...bu
a little tip is always welcome

--
Zur
-----------------------------------------------------------------------
Zurn's Profile: http://www.excelforum.com/member.php...fo&userid=1464
View this thread: http://www.excelforum.com/showthread.php?threadid=26412


Tom Ogilvy

Jump to next sheet if not found
 
Dim sh1 as Worksheet, sh2 as Worksheet
Dim i as long, bFound as Boolean
bFound = False
set sh1 = Worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
for i = 11 to 203 step 24
if isempty(sh.Cells(i,3)) then exit for
if sh1.Cells(i,3) = cellrun then
sh1.Activate
cells(i,3).Select
bfound = True
exit for
elseif sh1.Cells(i+1,3) = cellrun then
sh1.Activate
cells(i+1,3).Select
bFound = True
exit for
end if
Next
if not bFound then
for i = 11 to 203 step 24
if isempty(sh2.Cells(i,3)) then exit for
if sh.Cells(i,3) = cellrun then
sh2.Activate
cells(i,3).Select
bfound = True
exit for
elseif sh2.Cells(i+1,3) = cellrun then
sh.Activate
cells(i+1,3).Select
bFound = True
exit for
end if
Next
End if

if not bFound then
msgbox "Not found"
exit sub
End if


--
Regards,
Tom Ogilvy

"Zurn" wrote in message
...

Hello,


I'm trying to program a search the content of certain cells of two
different sheets. When click on a button, program asks for
RUN-nr...(=cellRun)
Then program has to search first in sheet one, when finding an empty
cell, the same search in sheet2. On the active cell, I run an other
adjust program.


-Worksheets("sheet1").Activate
Range("C11:C12").Activate
Do While cellRun < ActiveCell
ActiveCell.Offset(rowOffset:=24).Activate
If IsEmpty(ActiveCell) Then
Exit Do
End If
Loop-

Now my problem: If I work with a DO LOOP in a Do Loop, the program
isn't working.


several attempts didn't work...I'm not willing to give up trying...but
a little tip is always welcome.


--
Zurn
------------------------------------------------------------------------
Zurn's Profile:

http://www.excelforum.com/member.php...o&userid=14645
View this thread: http://www.excelforum.com/showthread...hreadid=264122





All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com