Excel Macro Search Debug Error

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
I am using a button and using search to search for term "Resize to show all values" currently it is searching for term and selecting it, but if it is not found it shows me debug error
please help me fix this error, if result is not found I want it do nothing may be if result is not found select cell A1 or something like that here is my code
Code:
Private Sub CommandButton2_Click()
Range("C1").Select
Cells.Find(What:="resize to show all values", After:=ActiveCell, LookIn:= _
        xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext _
        , MatchCase:=False, SearchFormat:=False).Activate

End Sub
 
I am sorry it worked, I forgot that my column A wasn't freeze anymore

I am total n00b at VBA
 
Last edited by a moderator:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
No problem at all...give this a whirl:

Code:
Sub test()
Dim foundCell As Range

Set foundCell = Cells.Find(What:="resize to show all values", After:=ActiveCell, LookIn:= _
        xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext _
        , MatchCase:=False, SearchFormat:=False)

If Not foundCell Is Nothing Then
    foundCell.Activate
Else:
    Range("A19").Activate
End If
End Sub
 
Upvote 0
that works well too, sorry I know I am asking too much... but I am working with huge database, in which I can read data like 1/100000 of the second so imagine how much data is there even A65536 is not enough.. I was wondering if not found it would try to search next and even not found go to 0 or something. go to 0 works better for me because I have column A freeze.
thanx again
 
Upvote 0
Do you understand what on Error GOTO 0 means?

<TABLE><TBODY><TR><TD>On Error GoTo 0</TD><TD>Disables any enabled error handler in the current procedure.</TD></TR></TBODY></TABLE>

it doesn't send you anywhere of the sheet
 
Upvote 0
ok oky that makes sense, I don't know why I said it goes on top of the sheet, may be it does go on top of the sheet after what I am doing to it.
 
Upvote 0
Sorry, re-reading my post wasn't clear. I should have said (as CharlesChuckieCharles pointed out) that:

For what it's worth, mine doesn't go to 0 (which you're interpreting as a spreadsheet location) it turns error checking back on.

Either way, do you now have an acceptable solution or is there something else you need? I'm not sure what you mean by "...I was wondering if not found it would try to search next and even not found go to 0 or something. go to 0 works better for me because I have column A freeze."
 
Last edited:
Upvote 0
HURRAY!! Glad everything is sorted out. Best of luck with the rest of your project.
 
Upvote 0
lol thanx one more idea, I came up with, some where in this project I am using auto clicker, so and that auto clicker is clicking this marco/vba code button, since I cannot program the auto clicker, I can program the excel auto clicker right, may be with help from you guys.

ok here is what I thought,
if result is not found can I have excel press "Ctrl+10" to stop the auto clicker from keep on clicking on search button.

please help me know if you understand my question
Thank you once again
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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