Search Box Macro Script To Search Using Filters In Sheet

Search Box Macro Script To Search Using Filters In Sheet

Hi there,

There are ways to create a search box in excel using a VBA. The main macro code is pasted below.

I was wondering if this could be doable with Zoho sheet. Would this code work? Or, do you guys have a solution to search the sheet and filter the results?

Thanks,
Chad

  1. Sub SearchBox()
    'PURPOSE: Filter Data on User-Determined Column & Text/Numerical value
    'SOURCE: www.TheSpreadsheetGuru.com

    Dim myButton As OptionButton
    Dim SearchString As String
    Dim ButtonName As String
    Dim sht As Worksheet
    Dim myField As Long
    Dim DataRange As Range
    Dim mySearch As Variant

    'Load Sheet into A Variable
      Set sht = ActiveSheet

    'Unfilter Data (if necessary)
      On Error Resume Next
        sht.ShowAllData
      On Error GoTo 0
      
    'Filtered Data Range (include column heading cells)
      Set DataRange = sht.Range("A4:E31") 'Cell Range
      'Set DataRange = sht.ListObjects("Table1").Range 'Table

    'Retrieve User's Search Input
      mySearch = sht.Shapes("UserSearch").TextFrame.Characters.Text 'Control Form
      'mySearch = sht.OLEObjects("UserSearch").Object.Text 'ActiveX Control
      'mySearch = sht.Range("A1").Value 'Cell Input
      
    'Determine if user is searching for number or text
      If IsNumeric(mySearch) = True Then
        SearchString = "=" & mySearch
      Else
        SearchString = "=*" & mySearch & "*"
      End If
        
    'Loop Through Option Buttons
      For Each myButton In sht.OptionButtons
        If myButton.Value = 1 Then
          ButtonName = myButton.Text
          Exit For
        End If
      Next myButton
      
    'Determine Filter Field
      On Error GoTo HeadingNotFound
        myField = Application.WorksheetFunction.Match(ButtonName, DataRange.Rows(1), 0)
      On Error GoTo 0
      
    'Filter Data
      DataRange.AutoFilter _
        Field:=myField, _
        Criteria1:=SearchString, _
        Operator:=xlAnd
      
    'Clear Search Field
      sht.Shapes("UserSearch").TextFrame.Characters.Text = "" 'Control Form
      'sht.OLEObjects("UserSearch").Object.Text = "" 'ActiveX Control
      'sht.Range("A1").Value = "" 'Cell Input
      
    Exit Sub

    'ERROR HANDLERS
    HeadingNotFound:
      MsgBox "The column heading [" & ButtonName & "] was not found in cells " & DataRange.Rows(1).Address & ". " & _
        vbNewLine & "Please check for possible typos.", vbCritical, "Header Name Not Found!"
      
    End Sub

    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Introducing Forms in Zoho Sheet

                                                              We hereby bring you the power of ​forms in Zoho Sheet. ​Now, build and create your own customized forms using Zoho Sheet. Be it compiling a questionnaire or rolling out a survey, Zoho Sheet can do it all for you. Forms is an excellent feature that helps you collect information in the simplest of ways and having it in Zoho Sheet takes it a notch higher. Build Simple yet Powerful forms Building forms using Zoho Sheet is fairly simple. The exclusive 'Form' tab lets you create one quickly. Whether you
                                                            • Meet the latest feature of Zoho Sheet: Lock Cells

                                                              We are happy to announce the release of one of the most awaited features in Zoho Sheet. ​You can now lock the cells that you wish to keep ​secure. Once you are done with editing cells, you can lock them so that they won't be modified anymore. We believe that this feature will be a great addition to our existing set of collaboration features and is intended to improve your collaboration experience. You can access this new feature Lock from Data tab. Apart from being able to lock individual cell ranges,
                                                            • Feature enhancement: Highlight rows based on a cell value

                                                              Hello Sheet users, We're excited to announce a new feature enhacement, shaped directly by your valuable feedback! As you might know, conditional formatting is a great tool for anyone dealing with large data sets. Previously, if you’ve ever wanted to draw
                                                            • Revamped Print in Zoho Sheet—customized for paper

                                                              The latest enhancements to Zoho Sheet's Print settings allows you to print a worksheet or a selected range, with customizations that make the data comprehensible, even on paper.   Customize header and footer Make your spreadsheets meaningful with a relevant header and footer. You can now choose to display the file name, sheet name, current page number, total pages, date, and time as the header and footer in your print view. Besides the predefined elements, you can also give a custom text for header/footer.
                                                            • Slicers are now available in Zoho Sheet—filter your data interactively

                                                              At Zoho Sheet, we diligently track user requests and feedback. In line with this, based on extensive user requests, we've integrated Slicers to pivot tables and are delighted to announce its release. Slicers are interactive visual filters that have add,


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Generating Discount Coupons for Zoho Bookings

                                                                                                              Hi, Is there provision to generate Discount Coupons for appointment bookings? I could not see that in the settings and this is very much needed. Please suggest us. Thanks
                                                                                                            • How do I remove mail hosting?

                                                                                                              I have a problem, I can't remove mail hosting. I need to remove them to cancel my domain, but it's imposible to cancel or remove the mail hosting. Please I need help urgently to resolve this problem.   Thanks
                                                                                                            • Notes created in mobile app not syncing with web notebook

                                                                                                              I have created certain notes in a new notebook in mobile app. The new notebook is also created using mobile app and when I logged in through web I am unable to see notebook that I have created using mobile app. there is no trace of notes in which i have created in mobile app on the web even after days of creating in mobile app This is not the case vise-a-versa. the notes and note book created on web are accessible on mobile app on real time.  this is very inconvenient and big demotivating factor
                                                                                                            • Desk - CRM Integration: SPAM Contacts (Auto Delete)

                                                                                                              SPAM contacts is a useful feature, but when the CRM sync is used, it is very frustrating. When a contact is marked as SPAM on Desk, I wish to do the same on CRM. When a SPAM contact is deleted, I would like it deleted from CRM. The feature looks half-baked.
                                                                                                            • No more IMAP/POP/SMTP on free plans even on referrals with NO NOTICE

                                                                                                              Outraged. Just referred a colleague to use her domain (not posting it publicly here) to Zoho, just as I have other colleagues, clients, friends. Expected the exact same free plan features as I have and as everyone else I ever referred got. I was helping
                                                                                                            • Mac Thunderbird zoho e mail account issues

                                                                                                              I have issues with a user account on thunderbird e mail client who suddenly does not receive emails, when you click get messages we get an error "sending of password for user ......did not succeed, mail poppro.zoho.com responded service unavailable" after
                                                                                                            • PASSWORD

                                                                                                              Hello, I'm Joyce, my client used zoho for password sharing, he did share the canva but once I clicked on it it will not automatically log-in, instead I need to log-in again. My question is my boss log-in first to his gmail and use his gmail to log-in
                                                                                                            • Kaizen #195: Frequently Asked Questions on Bulk Read API and Bulk Write API

                                                                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                                                                            • admin problem

                                                                                                              i can't to reach for the panel that i will create another mail to our company account i have admin access but i can't reach the panel our Company name Scale point my mail asmaa@dcalepointhub.com please can you help me Thanks
                                                                                                            • 554 5.7.1 : Recipient address rejected: user [username] does not exist

                                                                                                              Hi, I mistakenly altered my shopify email settings (where my domain is managed), but immediately reverted them, however now I have a strange email issue. I can send emails just fine, but cannot receive them. I have tried all troubleshooting steps but
                                                                                                            • Legit email address?

                                                                                                              Hello, I received emails from zohoadmin@biznetvigator.com with a password expiry notice. is that a legitimate email?
                                                                                                            • SMTP Authentication Fails with App Password – “535 Authentication Failed” Error

                                                                                                              Hello, I'm trying to send transactional emails from my WordPress website using the WP Mail SMTP plugin with Zoho Mail (smtp.zoho.com on port 465 with SSL). I've created and used a Zoho Mail app-specific password for SMTP, and verified that: The email
                                                                                                            • Deluge script issue : Mismatch of data type expression. Expected BIGINT but found STRING

                                                                                                              I'm building a Zoho Creator form to take inputs for Email, Bootcamp Name, and Tag. If a record with the same Email + Bootcamp exists in a custom module (bootcampattendence), I want to update it by adding a new tag. If it doesn’t exist, I want to create
                                                                                                            • Survey end date extension

                                                                                                              Hi, Is there any way to extend the end date of my survey? I needed more time in finding respondents that is why I need to extend the end date of my survey. Help. Thanks
                                                                                                            • Problem with signature in a forwarded mail

                                                                                                              Dear All, In my email account I created a signature and I unchecked the 'Place signature above the quoted text for relies and forwards' My question is, when I am trying to forward an email, sometimes I need to insert my signature so I select it from the
                                                                                                            • Out of Office not working

                                                                                                              I have set up out of office on zoho mail, however, it does not reply to every mail sent to it. I have tested it by sending several test messages from multiple different email accounts, I will get a response to some of them, but not all of them this is
                                                                                                            • Error message that says only images and no text

                                                                                                              I filled out a template for a weekly newsletter with text and images throughout but when I click save and next an error message comes up that says "Campaign content has only images and no text" which is not true at all. I have no idea how to fix this issue and don't know where the problem is. 
                                                                                                            • Contacts Don't Always Populate

                                                                                                              I've noticed that some contacts can easily be added to an email when I type their name. Other times, a contact doesn't appear even though I KNOW it is in my contact list. It is possible the ones I loaded from a spreadsheet are not an issue and the ones
                                                                                                            • Cannot add zoho email to gmail acc

                                                                                                              I'm trying to set up my zoho mail to connect to my gmail acc but no matter what I try I always get this problem. What should I do now? Password is up-to-date. Authentication failed. Please check your username/password. [Server response: 535 Authentication
                                                                                                            • 553 Relaying disallowed - Invalid Domain

                                                                                                              I have this error "553 Relaying disallowed. Invalid Domain" when sending an email to any email address. But I still receiving email from other emails. I checked MX, DKIM, SPF and it's ok. Could you check and help? Thanks
                                                                                                            • Turn off Organization Contact List

                                                                                                              We need to be able to turn off the Organization Contact list for some of our staff. Once the Organization Contact list is turned off for a user, we would then like to be able to create a list of contacts on per user basis that would not be editable by
                                                                                                            • Unable to send massage Reason 553/ Relaying Disallowed. Invalid Domain

                                                                                                              Cant sed massages from my email. All massages from my domain received the same issue Unable to send massage Reason 553/ Relaying Disallowed. Invalid Domain
                                                                                                            • Kaizen #194 : Trigger Client Script via Custom buttons

                                                                                                              Hello everyone! Welcome back to another interesting and useful Kaizen post. We know that Client Scripts can be triggered with Canvas buttons and we discussed this with a use case in Kaizen#180. Today, let us discuss how to trigger Client Script when a
                                                                                                            • Make record entry more organized with the Sections component in Wizards

                                                                                                              Hello everyone! Wizards in Zoho CRM have always helped you break long record-detail pages or large sets of fields into multiple screens, making data entry smoother and more user-friendly. Now, we’re taking a major step forward with a new Sections component—giving
                                                                                                            • GSTIN Public Search API

                                                                                                              Does zohobooks have an api using which i can search GST numbers and get their details?
                                                                                                            • External @zoho.com mail stopped working today, yesterday no issues

                                                                                                              Hello, Over a sudden mail stopped being delivered to inbox. Domain is standard zoho.com worked no problem yesterday, today nothing in inbox. Sent several test emails from corporate account & from gmail.com, logs show acceptance by zoho mail server, but
                                                                                                            • Suggestion: Smart Purchasing Module for Zoho Inventory and Zoho Books

                                                                                                              Suggestion: Smart Purchasing Module for Zoho Inventory and Zoho Books As an active user of Zoho Inventory and Zoho Books, I’ve noticed that the suite already provides valuable tools for managing inventory, analyzing trends, and processing purchase orders.
                                                                                                            • Adding bank details to the contact through API

                                                                                                              How to add bank-related information to the contact while creating it using API? The account number needs to be encrypted before sending it through API but not sure how to encrypt and get those values. Please guide me in this.
                                                                                                            • average cost display

                                                                                                              Hello there, I'm using the average cost valuation method, and the cost price shown in the Items menu should reflect the latest WAC (Weighted Average Cost). However, it doesn't update automatically. Is there a way to display the current average cost without
                                                                                                            • Apple Mail issues

                                                                                                              Dear Sir or Madam, I am trying to configure my Zoho mail account to Apple Mail. It is not working. It seems to need more information (perhaps a path prefix?) than is shown in your tutorial (<www.zoho.com/mail/help/apple-mac-imap.html>). After plugging
                                                                                                            • Assistance Required for Migrating Data from Odoo Inventory to Zoho Inventory

                                                                                                              Hi Team, I previously used Odoo Inventory to manage my stock and transactions, and I’ve now moved to Zoho Inventory. I’d like to migrate my data from Odoo—including product details, stock, purchase, and vendor information- into Zoho Inventory for continuity
                                                                                                            • I need my entire Zoho Account (mail/organization) deleted!

                                                                                                              Hey! I used zoho for my email aaron@aaronglass.me with domain forwarding/mx all that. I got rid of the mx info on my godaddy account and still Google won't let me sign up with my aaron@aaronglass.me email. (I'm moving to Google for business) SO! I was
                                                                                                            • Error: "Invalid Element warehouse_id" when sending order to Zoho

                                                                                                              i'm getting the error "Invalid Element warehouse_id" when trying to send an order to Zoho via API. Has anyone faced this issue before? How can I fix it?
                                                                                                            • No way to sell individual and case units smoothly in Zoho

                                                                                                              Currently, Zoho Inventory handles inventory primarily at the case level, which can be challenging for businesses that frequently need to break down cases into individual units for retail sales or smaller shipments. Although Zoho Inventory currently supports
                                                                                                            • How to handle multiple languages (Resume parser, Job opening, job board, career site) ?

                                                                                                              We are looking to bring Zoho Recruit to a market that needs to support 2 languages. The first thing we need to make sure is that the Candidate be flag with the language they speak. This is easy enough make a custom field that as the desire languages.
                                                                                                            • Shipping Labels

                                                                                                              Hi, Can we generate Packing Labels for manual shipping same as the format as Airway Bill in zoho books or inventory?
                                                                                                            • Unit Measurement Sign,

                                                                                                              Dear Zoho Support Team, I hope you are doing well. We recently purchased Zoho Inventory based on recommendations of your team that “it would be a great fit for our Shopify operations”. However, we are currently facing several urgent issues that require
                                                                                                            • Leadchain into a custom module

                                                                                                              Hello ZOHO Community ! is it possible to put the leads collected by leadchain into a custom module instaed of leads module ? Best wishes Niels
                                                                                                            • Urgent: How to Bulk Upload Images in Zoho Inventory? Any Workarounds?

                                                                                                              We are currently onboarding 5,000+ items from Shopify into Zoho Inventory, but we’re struggling with the lack of a bulk image upload feature. Right now, we have to manually upload and assign images one by one, which is extremely time-consuming and inefficient.
                                                                                                            • Can I automatically update COGS and Inventory account when creating an item?

                                                                                                              I have been trying to get Zoho to update the other two fields when I update one (Sales Account, COGS account, and Inventory Account). I know this seems like not a huge time saver, but I am all about efficiency and being an independent taproom, I create
                                                                                                            • Next Page