"Find" Macro error

tmanger

Board Regular
Joined
Jul 15, 2002
Messages
101
Hello all,

I have a small macro that helps the user search a database of food items for a calorie diary. This is my problem: it works fine for my machine at home running Excel 2000, but hangs with an error message (Run time error 1004) on my computer at work running Excel 2002.

This is the code:

Private Sub SearchFDbase1_Click()
Worksheets("Food Database").Activate
Cells.Select
Application.Dialogs(xlDialogFormulaFind).Show
End Sub

Ironically, if I remove the "Cells.Select" line, it runs fine on Excel 2002. Should I use "On Error Resume Next"?

As an aside, when I run the macro in Excel 2000 without the "Cells.Select" it runs, but the "Find" form is unable to search the database sheet.

Thanks in advance.

Tom.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
something like this.

Selection.SpecialCells(xlCellTypeLastCell).Select
Range(Cells(1, 1), Cells(ActiveCell.Row, ActiveCell.Column)).Select
 

tmanger

Board Regular
Joined
Jul 15, 2002
Messages
101
I need to search many cells. I have tried entering the range (A1:N12000) but I get a similar error.

if I use

Selection.SpecialCells(xlCellTypeLastCell).Select
Range(Cells(1, 1), Cells(ActiveCell.Row, ActiveCell.Column)).Select

I still seem to get a run time error.

The On Error Resume Next statement works, but I hate to use so liberally.

Tom.
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959

ADVERTISEMENT

Does the Find work ok in 2002 with the On Error Resume Next ?

If so, then my advice, don't bang your head with that anymore... sometimes Excel (and VBA) can be, mhm..., stubborn.
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
it works on my xcel2000.
it has selected A1 to the last cell with value.
I dont know about 2002.
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
one more try.
on xcel press F5, special cells and tick last cell if whats the last
cell.
 

tmanger

Board Regular
Joined
Jul 15, 2002
Messages
101
I appreciate the suggestions, I'll give them a try. Perhaps referring to the range as a name will allow the workaround.

Tom.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,307
Messages
5,641,436
Members
417,209
Latest member
Agbarker

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
Top