Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Macro Random Behavior

Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list. That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Macro Random Behavior

Hello Otto,

Have you tried starting at the same location, say A1, after you select the
two sheets?

HTH, Greg

"Otto Moehrbach" wrote in message
...
Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list.

That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Macro Random Behavior

Greg
Thanks for your reply. I don't know what you mean by "starting at the
same location". I tried putting [A1].Select after the two pages were
selected but that didn't help. Otto
"Greg Koppel" wrote in message
...
Hello Otto,

Have you tried starting at the same location, say A1, after you select the
two sheets?

HTH, Greg

"Otto Moehrbach" wrote in message
...
Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list.

That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list

was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the

MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your

help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro Random Behavior

I would try searching each sheet separately:

Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
With Worksheets("Air Compressor")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With

if FoundCell is nothing then
With Worksheets("Bay Door")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With
End If
if Not FoundCell is Nothing then
MsgBox FoundCell.Address(external:=True)
Else
MsgBox "Target was not found"
End If
End Sub

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list.

That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Macro Random Behavior

Tom
I appreciate your help. I'll give it a try. The macro I posted is an
abbreviation of the whole thing I have to demonstrate my problem. The code
will have already set up an array of some 18 sheets. I'll try what you
suggest and just use a For loop to loop through the sheets in the array
rather than select the entire array as I have been doing. Something like:
For i = 1 To ShtArray.Count
With Worksheets(ShtArray(i))
Do you see anything wrong with that?
Thanks again. Otto
"Tom Ogilvy" wrote in message
...
I would try searching each sheet separately:

Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
With Worksheets("Air Compressor")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With

if FoundCell is nothing then
With Worksheets("Bay Door")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With
End If
if Not FoundCell is Nothing then
MsgBox FoundCell.Address(external:=True)
Else
MsgBox "Target was not found"
End If
End Sub

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list.

That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list

was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the

MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your

help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Macro Random Behavior

Tom
Thanks again. I massaged what you gave me and fit it into my code and
it works like a charm. I won't try to search grouped sheets by code again.
Otto
"Tom Ogilvy" wrote in message
...
I would try searching each sheet separately:

Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
With Worksheets("Air Compressor")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With

if FoundCell is nothing then
With Worksheets("Bay Door")
Set FoundCell = .Columns(F).Find(What:=SearchPart, _
After:=.Range("F65536"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
End With
End If
if Not FoundCell is Nothing then
MsgBox FoundCell.Address(external:=True)
Else
MsgBox "Target was not found"
End If
End Sub

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2003, WinXP
I have been battling this one all day, trying to find a pattern to the
behavior of this macro. I can't. It appears to be completely random.
I have two sheets.
I take all of the Column F data from each sheet and formulate a list.

That
list is in the Data Validation [D32] in the Enter Data sheet.
I select one item in D32. That item now remains constant.
The following macro simply searches the two sheets from which the list

was
taken, for [D32] of the Enter Data sheet.
The problem: Sometimes it finds the item. Sometimes it doesn't.
I have tried every which way to find a pattern in the macro behavior but
couldn't. Sometimes it finds it in alternating executions of the macro.
Other times it doesn't. The error highlight is, of course, in the

MsgBox
line.
Does anyone have an idea of what I am doing wrong? Thanks for your

help.
Otto
Sub Test()
Dim FoundCell As Range
SearchPart = Sheets("Enter Data").Range("D32").Value
Sheets(Array("Air Compressor", "Bay Door")).Select
Set FoundCell = Selection.Find(What:=SearchPart, _
After:=Selection(1), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=True)
MsgBox FoundCell.Row
Sheets("Enter Data").Select
[D32].Select
End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
weird macro behavior Dave F Excel Discussion (Misc queries) 0 November 30th 06 03:35 PM
Inconsistent Macro Behavior Sarah K Excel Discussion (Misc queries) 4 November 1st 05 10:36 PM
Strange Personal Macro Workbook Behavior stretch Excel Discussion (Misc queries) 4 August 4th 05 07:39 PM
Weird template/macro behavior ?? David Excel Programming 0 August 12th 03 04:33 PM
Weird template/macro behavior ?? Tom Ogilvy Excel Programming 0 August 12th 03 04:17 PM


All times are GMT +1. The time now is 09:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"