"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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
hi!
something like this.

Selection.SpecialCells(xlCellTypeLastCell).Select
Range(Cells(1, 1), Cells(ActiveCell.Row, ActiveCell.Column)).Select
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
hi!
it works on my xcel2000.
it has selected A1 to the last cell with value.
I dont know about 2002.
 
Upvote 0
hi!
one more try.
on xcel press F5, special cells and tick last cell if whats the last
cell.
 
Upvote 0
I appreciate the suggestions, I'll give them a try. Perhaps referring to the range as a name will allow the workaround.

Tom.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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