Error: my code searches only within one cell

anxoperez

Active Member
Joined
Oct 3, 2007
Messages
254
I'm trying to run the Find-dialogue upon Workbook open and I'm using this code. The problem is it performs the search only within whatever the active cell is, yet I want it to search forward (i.e., look for the next occurrence).

Can someone tell me how to do it?

Private Sub Workbook_Open()
'
' Macro2 Macro
'
Sheets("Memory").Select
Application.Dialogs(xlDialogFormulaFind).Show "", 2
End Sub

(I also want it to search for values and not formulas)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Maybe change this line
Code:
Sheets("Memory").Select
to
Sheets("Memory").Cells.Select
or for eg
Sheets("Memory").Range("A1:D100").Select
 
Upvote 0
That works and I had done something similar before. However I need to avoid Selecting any range, and this is why I wanted it to just look for the next occurrence within the sheet. The reason I don't want it to highlight a selection is because the many cells are color coded and when the findbox highlights the search result cell, I can't see it.
 
Upvote 0
So you want it to find the next occurrence rather than the occurrence that may appear in the activecell? You could just offset the acivecell eg:

Code:
Sheets("Memory").Select
Activecell.Offset(,1).Activate
Application.Dialogs(xlDialogFormulaFind).Show "", 2

Or did you mean the find dialog literally only searches the activecell? Wat version of Excel are you using? How many cells are selected at the moment the sheet is activated? if only a single cell, the dialog should search all cells on the sheet
 
Upvote 0
For some reason it doesn't work.

It still is searching only within the active cell and nothing beyond it.

I'll answer your questions:

- I want it to search in the whole sheet (so active cell AND the rest)
- But I don't want to specify an area because that highlights the searchable area and then I have a hard time spotting what if finds as the cells are color-coded.
- I'm using Excel 2011 for Mac
- Yes, I only have one cell highlighted when the doc is opened, but the core of the problem is that it only searches within a cell and not the entire sheet (I know this because the "no results" popup message only appears if I type something not contained within that cell).
 
Upvote 0
I can't figure out what the problem is. It's really weird because if I close the search dialogue and open it again it DOES search the whole document, but if I don't, it only searches within that one cell.

I'm going crazy I hope one of you geniuses out there can provide the solution.
 
Upvote 0

Forum statistics

Threads
1,224,270
Messages
6,177,574
Members
452,784
Latest member
talippo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top