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

                                                                                                            • Lookups from Standard Modules to Custom Modules

                                                                                                              I have created an "External Contacts" Custom Module for adding Contacts who aren't directly associated with a Customer or Vendor but who are related to Orders by being a Site Contact, Job Contact, Warehouse Contact, etc for third party. How can I go about
                                                                                                            • Run automation on quiz completion

                                                                                                              Hello, We're exploring Zoho Learn as a possible solution to creating some training courses to external users on our system. We'd like to run a workflow/ integration to Zoho CRM when a course is completed. Is this possible?
                                                                                                            • Dynamic user applications for CPQ?

                                                                                                              Hi, I've been enjoying getting to know CPQ, the Product Configurator and Price Rules components have been very useful, albeit with some issues. I have noticed that I don't have the power to decide which level of sales staff has permissions when it comes
                                                                                                            • Need details on search criteria for zoho.crm.searchRecords

                                                                                                              Hi, If I understood correctly the integrated functions (getRecords, searchRecords, etc..) I can use inside Functions in Zoho CRM are actually using the Zoho CRM V2 API. I am looking for all the field types and criteria I can use with searchRecords. The
                                                                                                            • Do my notebooks get transferred to a new phone?

                                                                                                              Hello I was wondering about a new phone and I'd like to know whether your notes are automatically transferred to the new device? Regards Will.
                                                                                                            • Client Script Error - Cannot read properties of undefined (reading 'CRM')

                                                                                                              Hi Guys I have a custom form, and I have a client Script set for onLoad of the new form. Below is the script I have defined and the error: Cannot read properties of undefined (reading 'CRM') See Screen Shot Attachement for Details. Here is the Script:
                                                                                                            • Notebook sync

                                                                                                              Hi,After Restart Mobil-Phone since i pressen „Synchronisation“ in my Notebook-App (iPhone) the App is hanging all the time and I have no possibility to Break up. Also Not After Restart my mobile-Phone. After the Restart ( inkl. Connection to WiFi or mobile
                                                                                                            • Employee survey data when the survey creator's account is deleted

                                                                                                              I can’t find in the documentation on this topic, so asking here. When the employee who has created an Employee Engagement survey leaves the organisation and their Zoho account is deleted, will the survey results still be accessible to other persons if
                                                                                                            • DANE IS NOT implemented

                                                                                                              According to the answer of @Sagar S , "DANE has been implemented". on this topic Allow me to disagree, DANE is not implemented at least not to the EU area. The Zoho domain is not under DNSSEC protection and the related TLSA DNS records
                                                                                                            • Enhance Your CRM Experience with Zoho Webinars in Sandbox Environments

                                                                                                              Greetings all, Zoho Webinars will now be available for testing and deployment in Zoho CRM's sandbox environment. Sandboxes offer a safe way to replicate production environments and enable risk-free testing, training, and refining processes before making
                                                                                                            • Increase the elegant comparator to more than 5 users

                                                                                                              Hi Team Requesting to increase the elegant comparators number of custom users to more than 5, this is such a crucial tool in dashboarding but 5 users is simply not enough.
                                                                                                            • No emails coming in

                                                                                                              Hi, I am not receiving any emails, I have tried to send myself an email from another acct and I am not receiving anything, possibly for the last few days. Bit desperate as we are a nursery and not getting important emails from our parents.
                                                                                                            • Problem with Schedule Email parameters in "Send Reply to an Email" API

                                                                                                              Hello, This is my Json script: { "fromAddress": "test@gmail.com", "toAddress": "{{8.fromAddress}}", "subject": "{{8.subject}}", "content": "{{4.result}}", "action": "reply", "isSchedule": true, "scheduleType": 6, "timeZone": "Europe/Lisbon", "scheduleTime":
                                                                                                            • What's New? - May 2025 | Zoho Backstage

                                                                                                              Hi everyone, A May-zing month for you! As summer rolls in and event season picks up the pace, we’ve been working on a set of updates in Zoho Backstage to help make your day-to-day life a little easier. This month’s improvements are all about tackling
                                                                                                            • Integrate Zia AI into Zobot with Support for Hebrew and Bot Context

                                                                                                              Dear Zoho SalesIQ Team, Greetings. We would like to submit a feature request that would significantly enhance the functionality and intelligence of Zobot: native integration of Zia AI into Zobot scripts and blocks—with full support for Hebrew language
                                                                                                            • Mail Merge: Need Transparent Background for Signatures

                                                                                                              I'm using ZohoCRM and Zoho sign to send documents to customers to sign. We use zohoCRM's "Mail merge" option to create the templates. The problem is that those "Signature" fields have a solid white background so it looks like a stamp on the page instead
                                                                                                            • Zoho Flows

                                                                                                              Basically I can't build a connection that works between Excel on OneDrive and Zoho. I wanted to have 1 flow checking on a row added to an excel file and then intiate an import of that row. I'm doing that manually now and thought that this could be automated.
                                                                                                            • Zoho time tracking with automated screenshots

                                                                                                              Time tracking option with automated screen shots would be an exeptuonally good feature, any plans to develop something like that?
                                                                                                            • Sharing my portal URL with clients outside the project

                                                                                                              Hi I need help making my project public for anyone to check on my task. I'm a freelance artist and I use trello to keep track on my client's projects however I wanted to do an upgrade. Went on here and so far I'm loving it. However, I'm having an issue sharing my url to those to see progress. They said they needed an account to access my project. How do I fix this? Without them needing an account.
                                                                                                            • Zoho Campaigns Forms not Responsive on Website

                                                                                                              I have a mobile responsive Zoho Sites website and when I add a Zoho Campaigns form, it is not responsive. I have used the website code and ensured that the 'responsive' checkbox is selected. But, the form is not responsive to mobile. I have attached a
                                                                                                            • Oldest mail on top?

                                                                                                              I am old, and probably missing something simple, but how do I flip my zoho mail so oldest mail is on top?  Thanks in advance, and a HUGE thank you to the entire ZOHO team.  You just keep getting better!
                                                                                                            • Desk API to add or change commenterId to a comment

                                                                                                              Please let me know how to add comments on tickets for different agents using the API. When adding a comment it will take commenterId but then ignores that and used the API agentId. Did not see in API docs which values are readonly. I pleased to see commentedTime worked for past times. Regards, Glenn
                                                                                                            • How send a ticket attachment using the Sendreply API in Zoho Desk

                                                                                                              API document references : you make use of the Upload file API and gather the attachment ID. This ID is be passed with the Send email Reply API to deliver responses with the attachment intact. Code template is as below: // ORGID ORGID = "XXXXXXX"; // Masked
                                                                                                            • First Insight - Find your Fields

                                                                                                              The Wheels of Ticketing - Desk Stories Find your Fields What are fields? Fields are crucial in ticketing modules that capture information about Tickets, Customers, Organizations, Products, and more. Depending on the kind of data being stored, users can
                                                                                                            • Automation#30: Auto-Update Time Entry to the Nearest 5 Minutes

                                                                                                              Hello Everyone, Time tracking is a feature in Zoho Desk to help businesses stay organized and efficient. For Zylker Techfix, this feature has helped to track the duration of gadget services to generate accurate bills. However, Zylker Techfix faced a unique
                                                                                                            • Email adding to existing ticket

                                                                                                              hello Is there some syntax i can add e.g. to the subject line / body of my email that when it reaches the Zoho portal will add the request to an existing ticket. e.g {123} Currently if i have an open ticket and a customer emails me direct, i then forward
                                                                                                            • How to define different shift timings for each weekday in Zoho People?

                                                                                                              Hi everyone, We’re using Zoho People for attendance tracking and need to configure a standard 39-hour workweek that is structured like this: Monday to Thursday: 8 hours per day Friday: 7 hours Currently, our service provider has set up the workweek as
                                                                                                            • add two date range

                                                                                                              Hi, How can I add two date range selections to compare two different column values in a single pivot view? I have attached a snap for your reference.
                                                                                                            • Announcing new features in Trident for Windows (v.1.26.5.0)

                                                                                                              Hello Community, Trident for Windows is here with exciting new features to elevate your email communication and enhance productivity. Let’s dive into what’s new! Open .eml files in Trident. You can now open .eml files directly using Trident. This makes
                                                                                                            • Adjust The max character in Specification Field

                                                                                                              Is there another way to adjust the maximum character limit for the Specifications field in Zoho Commerce? I need to accept responses with fewer than 200 characters.
                                                                                                            • Customize the Sign In And Sign Up in Zoho Commerce

                                                                                                              Is there another way to customize the Sign In and Sign Up in website Zoho Commerce like this i want to customize to edit it like change the "Sign In" word into "Login Zoho Commerce" it is possible or other way to do that?
                                                                                                            • Territories : Deluge and APIs

                                                                                                              I am trying to work out how to filter a deluge query by territory eg "SELECT Total_Amount, Stage, Closing_Date, Created_Time, Deal_Name FROM Deals WHERE Stage in (" + varBaseCriteria + ") AND Territory = 'Territory1'" The problem being that Territory
                                                                                                            • Tidying up messes file system on Site

                                                                                                              I'm been given access to a new site that's been managed by several different people over the years, each with different ways of managing images and files. If I move an image from one folder to another, it shows a missing image icon on the site's page.
                                                                                                            • Move Archive Button in Zoho Mail to Main Toolbar?

                                                                                                              Is there a way to add the Archive Button to this tool bar so I don't have to click the three dots every time?
                                                                                                            • Introducing Bigin 360: Our new pricing edition with increased feature limits and pre-installed toppings

                                                                                                              Dear Biginners Club, Today, we're pleased to launch a brand-new pricing edition called Bigin 360, our highest pricing edition that will sit on top of Express and Premier editions. It's been over four years since our launch, and we're receiving some great
                                                                                                            • URL field display value

                                                                                                              Is it possible to give a URL stored in a project a display value, rather than showing the whole url? I have a lot of projects connected to issues filed on a separate site, each with a distinct URL. For example: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40000
                                                                                                            • need payment link excl. TDS Amount.

                                                                                                              Dear Team Zoho, Kindly generate a payment link excluding TDS amount. So that TDS can be submitted through portal. Thanks & Regards, Arijit S.
                                                                                                            • CRM is very slow now

                                                                                                              CRM is very slow now. Plz check ASAP
                                                                                                            • Access error when running invokeurl

                                                                                                              Hi, I'm running the following code: string standalone.test_api() { LoroToken=zoho.crm.getOrgVariable("LoroToken"); info "LoroToken:"+ LoroToken; headersMap = Map(); headersMap.put("Authorization", "Bearer "+LoroToken ); headersMap.put("Content-Type",
                                                                                                            • Disable Column Freeze in PWA View but Keep It on Desktop — Zoho Creator Reports

                                                                                                              Zoho Creator offers a useful feature to freeze up to two columns in a report view, which works well on desktops. However, our users access the app on both laptops and mobile devices, and freezing columns makes reports nearly unusable on smaller screens.
                                                                                                            • Next Page