VBA error in for - next loop

VBA error in for - next loop

Hi there
A few weeks ago I finished adjusting a code I had created in Excel to work with my Zoho Sheets file.
I was very happy with the result, as far as I know you are the only online application that supports Excel VBA.
When I opened the file today, after several weeks of inactivity, it returned an error in one macro which had not posed any problems when I worked with the file the last time.

Anywho, here's the code that returns an error:
  1. Sub ClearEmpty()

  2.   For k = 1 to 15
  3.       Worksheets(k).UsedRange.Select
  4.           For i = Selection.Rows.Count To 1 Step -1
  5.               If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
  6.                   Selection.Rows(i).EntireRow.Delete
  7.               End If
  8.           Next i
  9.   Next k
  10.   
  11. End Sub
And this is the error message I get: "Encountered error at line 11 :Application defined error"

Basically what this macro does is scroll through the first 15 sheets and deletes any empty rows.

    Access your files securely from anywhere











                            Zoho Developer Community





                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                            • Sticky Posts

                                                            • Zoho Docs EOL extended to March 15, 2023. Migrate to WorkDrive now!

                                                              Update: Zoho Docs access will be blocked for all users. Read this official post to know more. Most Zoho Docs individual and org users (including Workplace and Zoho One users) have already migrated their data and users to Zoho WorkDrive in response to
                                                            • Live Webinar - Drive your team towards tighter collaboration

                                                              Any project, big or small, involves a lot of planning, strategizing, scheduling, and budgeting. However, how your team executes the project really makes it a success. That's why teams need to work closer, stay dynamic, and be ready when they're needed.    However skilful your team might be, a collaboration platform can make them even more efficient and productive.    With organizations expanding globally, it's not only a challenge for teams to work together, but all to stay on the same page.    To
                                                            • Live Webinar: Collaboration Made Simple with Our Brand New Tool

                                                              Creating successful work groups when a team is geographically dispersed can be quite challenging. The process of keeping work and tasks in order becomes difficult and collaboration between team members can go haywire.  As a result, companies have shifted the way in which teams traditionally manage and organize their work. More organizations now want an exclusive, convenient place to work together, one that’s accessible by both internal and external collaborators.  That is why we have developed a
                                                            • Live Webinar - Go 'Pro Team' With Our New Productivity Tool

                                                              Is your team forced to keep switching between apps to get work done? Does it take everyone longer to complete their tasks?    Join us for a webinar on Thursday, May 17, 2018  to learn about our new product that'll transform the way you work and collaborate with teams across your organization - whether they are in the next room or even miles away.  Teams are dynamic and they require tools that are flexible enough to cope with the ever-changing environment. But working with your colleagues doesn't
                                                            • Live Webinar - Make the Most of your Team Collaboration

                                                              Do you have a collaborative team that's constantly looking for better ways to optimize productivity, connect with each other, and have better tools to share files? Well, look no further.   The Zoho Docs team has something big in store for you and your team. Join us on  Tuesday, April 17, 2018  to learn how to keep all your team files in one place, and turn you and your colleagues into productivity superstars! You'll also get a sneak peek at a new product that will help you:  Organize your team's


                                                            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

                                                                                                            • Zoho PDF editor has a lot of issues.

                                                                                                              Zoho PDF editor needs a lot of work. It hangs and glitches a lot. Deletes annotations and clearings randomly.
                                                                                                            • Zohom mail

                                                                                                              Plz resolve the problem . I hope u understand .
                                                                                                            • Workdrive on Android - Gallery Photo Backups

                                                                                                              Hello, Is there any way of backing up the photos on my android phone directly to a specific folder on Workdrive? Assuming i have the workdrive app installed on the phone in question. Emma
                                                                                                            • Clients not receiving emails

                                                                                                              I've been informed that my emails are not being received. Is there anything that I should look into to rectify this? Many thanks!
                                                                                                            • stock

                                                                                                              bom/bse : stock details or price =STOCK(C14;"price") not showing issue is #N/A! kindly resolve this problem
                                                                                                            • Zoho sheet desktop version

                                                                                                              Hi Zoho team Where can I access desktop version of zoho sheets? It is important as web version is slow and requires one to be online all the time to do even basic work. If it is available, please guide me to the same.
                                                                                                            • ZOHO SHEETS

                                                                                                              Where can I access desktop version of zoho sheets? It is important to do basic work If it is available, please guide me to the same
                                                                                                            • Zoho Books - France

                                                                                                              L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
                                                                                                            • Using Zoho Flow to create sales orders from won deal in Zoho CRM

                                                                                                              Hi there, We are using Zoho Flow to create sales orders automatically when a deal is won in Zoho CRM. However, the sales order requires "Product Details" to be passed in "jsonobject", and is resulting in this error: Zoho CRM says "Invalid input for invalid
                                                                                                            • Is Zoho Sheet available for Linux ?

                                                                                                              Is Zoho Sheet available for Linux ?
                                                                                                            • Bharat

                                                                                                              a
                                                                                                            • how to disable staff selection Zoho Booking integrated to SalesIQ?

                                                                                                              currently there is only one Consultant in my Zoho Bookings like this I integrate Zoho Bookings into Zoho SalesIQ to create a chatbot. Unfortunately, even though I only have one consultant for a consultation, the user have to pick the consultant. It will
                                                                                                            • Zoho Bookings No Sync with Outlook

                                                                                                              Zoho Bookings appointments are showing on my Outlook Calendar but Outlook events are not showing on Zoho Bookings. How do I fix this?
                                                                                                            • End Date in Zoho Bookings

                                                                                                              When I give my appointments a 30 minutes time I would expect the software not to even show the End Time.  But it actually makes the user pick an End Time.  Did I just miss a setting?  
                                                                                                            • Custom confirmation message

                                                                                                              How can I change the message that users see after they submit the booking form? I have to confirm some details before their appointment is officially "confirmed", so I want to change it where it doesn't say their appointment is "confirmed" but rather
                                                                                                            • Issue showing too many consultations in my workspace link.

                                                                                                              Hi Team, I’ve set up two Workspaces to track meetings from different sources. So far, this has been working well, and the two Workspaces are differentiated without any issues. However, when I navigate to Consultations and share the link to my personal
                                                                                                            • Deluge sendmail in Zoho Desk schedule can't send email from a verified email address

                                                                                                              I am trying to add a scheduled action with ZDesk using a Deluge function that sends a weekly email to specific ticket client contacts I've already verified the email address for use in ZDesk, but sendmail won't allow it in its "from:" clause. I've attached
                                                                                                            • Zoho Learn & Zoho Connect

                                                                                                              Hi, Is there a way to sync the knowledge base we have in Zoho Learn with the manuals section is Zoho Connect? Thanks,
                                                                                                            • Addin Support in Zoho Sheet

                                                                                                              Is there any addin support available in zoho sheet as like google marketplace to enhance productivity by connecting with other apps, providing AI data analysis, streamlining business processes, and more?
                                                                                                            • Changing Corporate Structure - How Best to Adapt Current and Future Zoho Instances

                                                                                                              My current company is Company A LLC with a dba ("doing business as" - essentially an alias) Product Name B. Basically, Company A is the legal entity and Product Name B is what customers see, but it's all one business right now. We currently have a Zoho
                                                                                                            • how to add subform over sigma in the CRM

                                                                                                              my new module don't have any subform available any way to add this from sigma or from the crm
                                                                                                            • How to Install Zoho Workdrive Desktop Sync for Ubuntu?

                                                                                                              Hi. I am newbie to Linux / Ubuntu. I downloaded a tar.gz file from Workdrive for installing the Workdrive Desktop Sync tool. Can someone give me step by step guide on how to install this on Ubuntu? I am using Ubuntu 19.04. Regards Senthil
                                                                                                            • How to upload own video?

                                                                                                              How can you upload your own video on your zoho website? I do not want to use another host, but i want to insert my own files. how can i do this?
                                                                                                            • Support new line in CRM Multiline text field display in Zoho Deluge

                                                                                                              Hi brainstrust, We have a Zoho CRM field which is a Muti Line (Small) field. It has data in it that has a carriage return after each line: When I pull that data in via Deluge, it displays as: I'm hoping a way I can change it from: Freehand : ENABLED Chenille
                                                                                                            • Announcing new features in Trident for Windows (v.1.32.5.0)

                                                                                                              Hello Community! Trident for Windows just got better! This update includes new features designed to improve and simplify email and calendar management—and it includes a feature you’ve been waiting for. Let’s dive into what’s new! Save emails in EML or
                                                                                                            • How to render either thumbnail_url or preview_url or preview_data_url

                                                                                                              I get 401 Unauthorised when using these urls in the <img> tag src attribute. Guide me on how to use them!
                                                                                                            • Zoho CRM Calendar | Custom Buttons

                                                                                                              I'm working with my sales team to make our scheduling process easier for our team. We primary rely on Zoho CRM calendar to organize our events for our sales team. I was wondering if there is a way to add custom button in the Calendar view on events/meeting
                                                                                                            • Max numbr of IMAP Accounts in Zoho Mail?

                                                                                                              In Zoho mail, you can manage the inboxes of other accounts using IMAP (and POP, actually) https://www.zoho.com/mail/help/external-imap-accounts.html Is there a max to the number of inboxes we can add?
                                                                                                            • Create Lead Button in Zoho CRM Dashboard

                                                                                                              Right now to create Leads in the CRM our team is going into the Lead module, selecting the "Create Lead" button, then building out the lead. Is there anyway to add the "Create Lead" button or some sort of short cut to the Zoho CRM Dashboard to cut out
                                                                                                            • Searching customer field

                                                                                                              Hello, When entering a receipt, we select customer information. The customer information is synced with Zoho CRM. However, we can't find the customer information because it searches for words that begin with the entered value. It needs to search for words
                                                                                                            • Introducing Version-3 APIs - Explore New APIs & Enhancements

                                                                                                              Happy to announce the release of Version 3 (V3) APIs with an easy to use interface, new APIs, and more examples to help you understand and access the APIs better. V3 APIs can be accessed through our new link, where you can explore our complete documentation,
                                                                                                            • Zoho CRM Tracking Google Enhanced Conversions

                                                                                                              Can anyone @Zoho, consultants, or users help me understand if Zoho CRM is going to support Google's Enhanced Conversions? I included some information from Google below about it. We use Google Adwords for our pay per click advertising for lead generation,
                                                                                                            • zoho click, and nord VPN

                                                                                                              Unfortunately, we've been having problems with Zoho Click, where essentially the line cuts off after about a minute's worth of conversation every time we are on VPN. Is there a way we can change this within the settings so it does not cut the line off
                                                                                                            • Connecting Portals from different Zoho apps

                                                                                                              Hi, I note that Zoho has functionality for customer portals for several of the Zoho apps, like CRM, Projects, Desk etc. Is there any way to connect these portals?  It would be great if we could give our customers access to a portal in which they could
                                                                                                            • Billing Management: #5 Usage Billing

                                                                                                              After understanding the nuances of Advance Billing and Retainers, we will explore one of the booming billing models. Long ago, villagers drew water from a shared well in a small village. The well was a lifeline for the entire community. Ravi, the well
                                                                                                            • Function #10: Update item prices automatically based on the last transaction created

                                                                                                              In businesses, item prices are not always fixed and can fluctuate due to various factors. If you find yourself manually adjusting the item rates every time they change, we have the ideal time-saving solution for you. In today's post, we bring you custom
                                                                                                            • Inventory Adjustments

                                                                                                              Hi, How to transfer the material from one head to another ? Like materials purchased for manufacturing the laptop need to transfer from consumption inventory (Quantity of raw materials reduced) to destination inventory ( Quantity of Laptop increased)
                                                                                                            • Zoho CRM Community Digest - Aug 2025 | Part 1

                                                                                                              Hey everyone! The first half of August went by, and we have a few announcements and some good noteworthy discussions. So, let's take a look at them! Product Updates: Introducing Connected Records feature: Zoho CRM’s Next-Gen UI now includes Connected
                                                                                                            • Please make it easier to Pause syncing

                                                                                                              right now it takes 3 clicks to get there. sounds silly, but can you make it just 2 clicks to get it done instead? thats how dropbox does it, 2 clicks to pause instead of 3.
                                                                                                            • How to create a Zoho CRM report with 2 child modules

                                                                                                              Hi all, Is it possible to create a Zoho CRM report or chart with 2 child modules? After I add the first child module, the + button only adds another parent module. It won't let me add multiple child modules at once. We don't have Zoho Analytics and would
                                                                                                            • Next Page