Object required error

Object required error

Hi,

I am getting an 'Object required' error on the line

Call HideColumnsOutsideRange(ws, startOfWeek, endOfWeek) 

when I run the ShowCurrentWeek macro but not when I run the ShowCurrentMonth macro. 

Any ideas?

Regards,
GW

Option Explicit

Sub HideColumnsOutsideRange(ws as Worksheet, startDate As Date, endDate As Date)
    Dim lastCol As Long
    Dim c As Long
    Dim hdr As Variant
    Dim dt As Date

    ' Find last used column in row 1
    Application.ScreenUpdating = False

    ws.Cells.EntireColumn.Hidden = False
    
    lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column

    For c = 1 To lastCol
        hdr = ws.Cells(1, c).Value

        If IsDate(hdr) Then
            ' Normalize to pure date (drop time / timezone artifacts)
            dt = DateSerial(Year(CDate(hdr)), Month(CDate(hdr)), Day(CDate(hdr)))
            ' Debug.print "dt: " & dt & " start: " & startDate & " end: " & endDate
            ' Hide if outside the given range
            If (dt < startDate) Or (dt > endDate) Then
                ws.Columns(c).Hidden = True
            End If
        Else
            ws.Columns(c).Hidden = True
        End If
    Next c

    Application.ScreenUpdating = True
End Sub

Sub ShowCurrentMonth()
    Dim ws As Worksheet
    Dim today As Date, startOfMonth As Date, endOfMonth As Date

    Set ws = ActiveSheet
    today = DateValue(Now)

    startOfMonth = DateSerial(Year(today), Month(today), 1)
    endOfMonth   = DateSerial(Year(today), Month(today) + 1, 0)

    Call HideColumnsOutsideRange(ws, startOfMonth, endOfMonth)
End Sub

Sub ShowCurrentWeek()
    Dim ws As Worksheet
    Dim today As Date, startOfWeek As Date, endOfWeek As Date

    Set ws = ActiveSheet
    today = DateValue(Now)

    startOfWeek = today - (Weekday(today) - 1)  ' Sunday–Saturday
    'Debug.Print "startOfWeek: " & startOfWeek
    endOfWeek = startOfWeek + 6

    Call HideColumnsOutsideRange(ws, startOfWeek, endOfWeek)
End Sub

      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          • Sticky Posts

          • What's new in Zoho Sheet: Simplify data entry and collaboration

            Hello, Zoho Sheet community! Last year, our team was focused on research and development so we could deliver updates that enhance your spreadsheet experience. This year, we’re excited to deliver those enhancements—but we'll be rolling them out incrementally
          • 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
          • 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,
          • Introducing Data Bars: Graphically represent changes in data within the cells

            Conditional formatting has helped millions of spreadsheet users analyze and highlight their data more efficiently. In addition to the classic rules, color scales, and icon sets available in Zoho Sheet, you can now apply Data Bars, a convenient method
          • 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

          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

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

                              Zoho CRM コンテンツ



                                ご検討中の方

                                  • Recent Topics

                                  • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

                                    The address field will be available exclusively for IN DC users. We'll keep you updated on the DC-specific rollout soon. It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition. Latest update
                                  • is there any way to change the "chat with us now" to custom message?

                                    is there any way to change the "chat with us now" to custom message? I want to change this text
                                  • Notes badge as a quick action in the list view

                                    Hello all, We are introducing the Notes badge in the list view of all modules as a quick action you can perform for each record, in addition to the existing Activity badge. With this enhancement, users will have quick visibility into the notes associated
                                  • Is Zoho Live Chat compatible with WordPress CMS?

                                    Hello, I have a website called www.jjrlab.com and I'm interested in using Zoho Chat on it. Does it support WordPress CMS? Thanks.
                                  • Introducing spam detection for webforms: An additional layer of protection to keep your Zoho CRM clean and secure

                                    Greetings all, One of the most highly anticipated feature launches—Spam Detection in webforms—has finally arrived! Webforms are a vital tool for record generation, but they're also vulnerable to submissions from unauthenticated or malicious sources, which
                                  • Bring your CRM and Desk app inside SalesIQ with widgets

                                    Have you ever been confused and frustrated with multiple open tabs and switching back and forth from SalesIQ to other apps to perform your business-specific operations? How effective would it be to have all the required tools and data of the apps you
                                  • Speak Your Customers' Language: SalesIQ's chatbots now support 30 languages 🤖

                                    We're unveiling some major upgrades to our chatbot that are set to revolutionize your experience! Now SalesIQ support 30 languages for both Zobot and Answer bot. By speaking your customers' language, you can enhance engagement, improve customer satisfaction,
                                  • Repeat Column merge in ZOHO writer columns doesn't allow to set max columns per row

                                    I'm using ZOHO writer to merge data from a ZOHO CRM subform and I want it to make a table. We're using Insert Table for Column Repeat, because this is what we need. (Name of column (Teamname) and underneath that a list of names of teammembers). It works
                                  • Persisting email signals to contact timeline?

                                    Hello there. Regarding the email signals that are logged when a contact opens an email, am I correct that these signals are not logged to a contact's timeline? Ideally, I would like to have this context available for future follow-ups, if the contact
                                  • Trouble with using Apostrophe in Name of Customers and Vendors

                                    We have had an ongoing issue with how the system recognizes an apostrophe in the name of customers and vendors. The search will not return any results for a name that includes the mark; ie one of our vendors names is "L'Heritage" and when entering the
                                  • Really want the field "Company" in the activities module!

                                    Hi team! Something we are really missing is able to see the field Company when working in the activities module. We have a lot of tasks and need to see what company it's related to. It's really annoying to not be able to see it.🙈 Thx!
                                  • Upcoming update to Google Drive integration in Zoho Creator

                                    Hello everyone, We're writing to inform you about an upcoming update to how Zoho Creator integrates with Google Drive. In Zoho Creator, during actions like importing files to create an app or attaching files to fields, you can choose files directly from
                                  • Changing Account Type in Chart of Accounts

                                    Does anyone know how to change/edit the account type for an Account name in Chart of Accounts. Zoho will not let me do this for some reason
                                  • Managing Scheduled Replies

                                    Communication is most effective when the intended message reaches the right person at the right time. However, this can be challenging when communication occurs across different time zones. By scheduling replies, businesses can ensure that responses reach
                                  • Show price book list price

                                    When using price books, once you add products to the price book in the Products related list you can display the Unit price which is the default list price; however, there is no option to show the price book list price. To see the price book list price
                                  • Allow Attaching Quartz Recordings to Existing Zoho Support Tickets

                                    Hi Zoho Team, We would like to request an enhancement to how Zoho Quartz recordings integrate with Zoho Support tickets. Current Behavior: At the moment, each Quartz recording automatically creates a new support ticket. However, in many real-world scenarios:
                                  • Issue with open-rate reporting in Zoho Campaigns

                                    Hello, Since yesterday I’ve been experiencing an issue with the open-rate reports in Zoho Campaigns. The campaigns I send appear in the reports as if none of the emails have been opened, even though I know they have. To verify this, I replicated the campaign
                                  • Can I hide empty Contact fields from view?

                                    Some contacts have a lot of empty fields, others are mostly filled. Is there a way I can hide/show empty fields without changing the actual Layout? I would like to de-clutter my view, and also be able to add information later as I am able. I would be
                                  • Manage user roles and profiles from the Bigin app (iOS and macOS)

                                    Hello everyone! We're happy to announce that you can manage user roles and profiles from the Bigin mobile app. The Users & Controls section has three subsections: Users, Profiles, and Roles. Users Employees who belong to your Bigin organization are called
                                  • Support Bots and Automations in External Channels

                                    Hello Zoho Cliq Team, How are you? We actively use Zoho Cliq for collaboration, including with our external developers. For this purpose, external channels are a key tool since they work seamlessly within the same interface as all of our other channels
                                  • Zoho Books Sandbox environment

                                    Hello. Is there a free sandbox environment for the developers using Zoho Books API? I am working on the Zoho Books add-on and currently not ready to buy a premium service - maybe later when my add-on will start to bring money. Right now I just need a
                                  • Form to PDF template

                                    I am looking to create a Form and when information is inputted, it will merge it into a PDF template we already have. There could be multiple lines in the form and each line inputs information into a new page of a PDF template.
                                  • Writing SQL Queries - After Comma Auto Suggesting Column

                                    When writing SQL Queries, does anyone else get super annoyed that after you type a comma and try to return to a new line it is automatically suggest a new column, so hitting return just inputs this suggested column instead of going to a new line? Anyone
                                  • Please verify my account

                                    Hi, We have just launched our website and received media coverage in our country. Hundreds of users are signing up for our platform every day. We would like to send them a welcome email, but we are unable to do so because our ZeptoMail account has not
                                  • Subject character limit increase

                                    We have an occasional user case where subject lines exceed 500 characters which is the ZeptoMail imposed limit. While I understand long subject lines are not "best practice", these are particular notification emails with specific information for client
                                  • Account blocked

                                    Yesterday I got my Zeptomail account blocked due to too many hard bounces. My account is used exclusively for sending transactional emails (eg. your order has been shipped, a form has been filled, etc) and the sudden blocking impacted hundreds of websites
                                  • Nested notebooks

                                    Dear Sir/Madam, I would like to know if it is possible to nest notebooks. It would be very helpful when there are too many, as it would improve organization. Thank you for your response. Best regards.
                                  • Cannot see correct DNS config for mail after moving domain to another provider

                                    I have moved my domain from one provider to another and after that zoho mail stopped working (expected). Problem is, zoho mail admin panel still shows (10 hours after move) that all records are correct while I haven't changed anything in my domain DNS
                                  • Proactive Alert for Existing Open Tickets per Contact / Account

                                    Hello Zoho Desk Team, Greetings, and hope you’re doing well. We would like to submit a feature request aimed at improving agent awareness and efficiency when handling tickets in Zoho Desk. Use case When an agent opens a ticket (new or existing), it is
                                  • Add the ability to Hide Pages in Page Rules

                                    Hi, We have Field Rules to show and hide fields and we have page Rules, but we can't hide a page in Page Rules so it isn't completed before the previous page (And then have the Deny Rules to prevent submitting without both pages completed), we can only
                                  • Ticket resolution field - can you add links, video, and images?

                                    Seems like the ticket resolution fields is just a text field. Any plans to add the ability to add links, images...the same functionality in the problem description box? I would like to send the customer a link to a KB article, a link to our Wiki, embed
                                  • Ticket Resolution - Add rich formatting, screenshots and attachments

                                    The resolution field only allows plain text at the moment. Many of our resolutions involve posting screenshots as evidence, it would be great for us to be able to have rich text formatting, be able to paste screenshots and add attachments in the solution
                                  • Deprecation Notice: OpenAI Assistants API will be shut down on August 26, 2026

                                    I recieved this email from openAI what does it means for us that are using the integration and what should we do? Earlier this year, we shared our plan to deprecate the Assistants API once the Responses API reached feature parity. With the launch of Conversations,
                                  • Deleting a memorized email address

                                    How can I delete a memorized email address? Even though the address has been deleted from Contacts, Zoho mail still auto suggests the address when typing it into the TO field. Thanks!
                                  • CRUD actions for Resources via API

                                    Hello, is it possible to perform CRUD actions through the API for Resources? We want to create a sync from Zoho CRM Car record to Bookings resources to create availabilities for Car bookings. For Test drives, not only the sales person needs to be available,
                                  • Kaizen #140 - Integrating Blog feed scraping service into Zoho CRM Dashboard

                                    Howdy Tech Wizards! Welcome to a fresh week of kaizen. This week, we will look at how to create a dashboard widget that displays the most recent blog post of your preferred products/services, updated daily at a specific time. We will leverage the potential
                                  • Convert Lead Automation Trigger

                                    Currently, there is only a convert lead action available in workflow rules and blueprints. Also, there is a Convert Lead button available but it doesn't trigger any automations. Once the lead is converted to a Contact/Account the dataset that can be fetched
                                  • I'm getting this error when I try to link an email to a deal inside the Zohomail Zoho CRM extension.

                                    When I click "Yes, associate," the system displays an "Oops!! Something went wrong" error message. I have attached a screenshot of the issue for reference.
                                  • Zoho Sheet - Desktop App or Offline

                                    Since Zoho Docs is now available as a desktop app and offline, when is a realistic ETA for Sheet to have the same functionality?I am surprised this was not laucned at the same time as Docs.
                                  • ZOHO add-in issue

                                    I cannot connect ZOHO from my Outlook. I am getting this error.
                                  • Next Page