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

                                                                                                            • To Zoho customers and partners: how do you use Linked Workspaces?

                                                                                                              Hello, I'm exploring how we can set up and use Linked Workspaces and would like to hear from customers and partners about your use cases and experience with them. I have a Zoho ticket open, because my workspace creation fails. In the meantime, how is
                                                                                                            • Zoho Forms to Zoho CRM : First/Last Name to just Name ?

                                                                                                              When integrating a Zoho Form into the Accounts menu of the CRM I'm having trouble with how names are formatted ; In Forms the data is available as First Name or Last Name In the CRM there is only one field called Name How can I ensure that "John" "Smith"
                                                                                                            • Enhancements to the formula field in Zoho CRM: Auto-refresh formulas with the "Now" function, stop formula executions based on criteria, and include formulas within formulas

                                                                                                              Dear Customers, We hope you're well! By their nature, modern businesses rely every day on computations, whether it's to calculate the price of a product, assess ROI, evaluate the lifetime value of a customer, or even determine the age of a record. With
                                                                                                            • This festive season, offer discounts with coupon code support in Stripe Checkout

                                                                                                              Hello form builders! It’s the festive season, the perfect time to spread joy and great deals! Now, with Zoho Forms’ latest enhancement for Stripe Checkout, you can do exactly that with coupon codes! Your payment forms integrated with Stripe Checkout can
                                                                                                            • Cómo creo una factura negativa o de abono?

                                                                                                              NEcesito anular una factura y crear una nueva igual pero en negativo. El sistema no me lo permite
                                                                                                            • Power of Automation::Streamline log hours to work hours upon task completion.

                                                                                                              Hello Everyone, A Custom Function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as to when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:-
                                                                                                            • can I link a contacts to multiple accounts

                                                                                                              can I link a contacts to multiple accounts
                                                                                                            • Is CRM On Premise available

                                                                                                              Hi Zoho team, Can you please let me know that CRM Zoho is available for On Premise as well? Thanks, Devashish
                                                                                                            • Last activity time is acting like last modified time

                                                                                                              When i edit the description or any field in the potential, account, contact and lead, the Last Activity Time is being updated like the Modified Time. This is messing all workflows and reports and we are unable to track real last time of activities like
                                                                                                            • CRM : Function to add user name to text field

                                                                                                              I have a lookup field in a module that is linked to the CRM users so we can assign a Project Lead to the customer. Sadly Zoho Marketing Automation doesn't sync Lookup fields so I need to extract information from the lookup to text fields: Lookup field
                                                                                                            • Zoho CRM - Restrict Login based on work hours

                                                                                                              Hi there, I'm wondering if we can restrict users to login during works - For example the users would be able to login from 8am to 5pm. I have seen the IP address restriction - the only downfall is what if the customer has dynamic IP. thanks Jiri
                                                                                                            • Tips and Tricks #46: Customize themes and templates using Show's Master View

                                                                                                              Hi All!  Let's say you want to revamp your presentation and make changes to its visual design. You can do this easily using the Master Slide and its associated layouts. The Master Slide stores information about all the layouts used in the presentation.
                                                                                                            • Currency abbreviations

                                                                                                              Hello, Im stuck, and need help. I need the currency fields for example, opportunity value, or total revenue, to be abbreviated, lets say for 1,000 - 1K, 1,000,000 - 1M, and so on, how should I do this?
                                                                                                            • Sheet View in CRM portal

                                                                                                              Hi, When will it be possible for my CRM portal users to edit/add records with Sheet View? George
                                                                                                            • What's New in Zoho Invoice | July - September 2025

                                                                                                              Hello everyone! We’re back with the latest updates and enhancements we’ve rolled out in Zoho Invoice from July to September 2025. Here’s what’s new this quarter: Introducing the Singapore Edition in Zoho Invoice Share Invoices through WhatsApp GST 2.0
                                                                                                            • Alert: Audio Call Support to be discontinued for Old Live Chat Widget from December 31, 2025

                                                                                                              Action Required: Upgrade to the New SalesIQ Live Chat Widget We're reaching out with an important update regarding the SalesIQ Live Chat Widget that requires your immediate attention. Effective December 31, 2025, audio call functionality will no longer
                                                                                                            • 【開催間近 - 10/17】東京 ユーザー交流会 Vol.3 参加登録 受付中!(参加無料)

                                                                                                              ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 10/17(金)に、東京・新橋で「東京 ユーザー交流会 Vol.3」を開催します! ZOHOLICSよりも小規模なイベントですので、「リアル開催はちょっと緊張する…」という方も、安心してご参加いただけます✨ 当日は、初公開の事例を2つご紹介予定です! なお、セッション映像のアーカイブ配信は予定していないため、会場にお越しいただいた方だけが、登壇者へ直接質問したり、リアルな声を聞いたりできる貴重な機会となっています。 ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
                                                                                                            • multiple contacts for one account

                                                                                                              We currently use Zoho CRM where each Account represents a club or organization, and each Contact represents a manager or owner. However, some of our managers own or manage multiple clubs, and Zoho only allows a contact to be linked to one account at a
                                                                                                            • Rich text Merge field - Not using font specified in HTML

                                                                                                              I have a rich text merge field in a writer template which is creating a table. I have chosen to use this method instead of a repeat region because I need to specify specific cell background colours which change every time the document is created. The
                                                                                                            • Can't change form's original name in URL

                                                                                                              Hi all, I have been duplicating + editing forms for jobs regarding the same department to maintain formatting + styling. The issue I've not run into is because I've duplicated it from an existing form, the URL doesn't seem to want to update with the new
                                                                                                            • ヒートマップ詳細設定について

                                                                                                              はじめまして マーケティング担当の浅田です。 PageSenceのヒートマップ設定について質問です。 単一ページ毎の設定は上手くできるのですが 詳細設定にて、トップページのURLを含ませ全体のヒートマップを計測できないか試したところ お知らせ:データを受信していません。と表示されてしまいます。 トップページURLで始まるページの条件も試しております。 全頁を反映させたいと思い、詳細設定を上手く設定できたらと考えております。 どなたか詳しい方がいらっしゃいましたら、教えて頂けませんでしょうか 宜
                                                                                                            • Automatic category assignment

                                                                                                              Hi, I’d like to ask if there is a way to automatically assign an expense category based on the recognized Merchant. What would be the simplest way to set up automatic category assignment? Alternatively, is there an option to first choose the category
                                                                                                            • Need Help to setup plugs along with codeless bot buidler. To send sms OTPs to users via Zoho Voice and to verify it

                                                                                                              Need Help to setup plugs along with codeless bot buidler. To send sms OTPs to users via Zoho Voice and to verify it. I get leads from our website and we need to make sure those are not junk. So we are using proactive chat bot and we need mobile OTPs to
                                                                                                            • Experience with Zoho Vertical Studio

                                                                                                              I'm considering Zoho Vertical and would love to hear from some devs who've been using it. The Zoho ecosystem is pretty solid, so I assume the experience has been pretty good, but sometimes Zoho has its quirks. Overall, has your experience been positive?
                                                                                                            • LinkedIn Chrome Extension

                                                                                                              Hello - I believe it is a known issue that the LinkedIn extension Resume Extractor has stopped working and they are working on potential fixes. Wondering how others users are finding this issue and if there are any better workarounds for this issue? It
                                                                                                            • Advance PDF creation from CRM data

                                                                                                              I'm trying to create a PDF export of data in the CRM. My problem is I want a pretty complicated format for the data. I'm trying to export multiple modules worth of data, with nested one-to-many relationships between the modules. Along with that, I want
                                                                                                            • 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.
                                                                                                            • Where does this report come from in the Zoho One ecosystems?

                                                                                                              Is this directly from MA, Analytics or ??? ???
                                                                                                            • Cliq iOS can't see shared screen

                                                                                                              Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
                                                                                                            • Sub-Form Padding in CSV Export

                                                                                                              Hi, When you use the Sub-Form, and for example you have a Date Field on the Main Page, then Option 1 and Option 2 fields on the Subform, when you export this to CSV the Date column will only have the Date in 1 row, the first row, it would be nice to pad
                                                                                                            • More Formula Functions

                                                                                                              Hi, I would ike for example to be able to have a Date Field and Formula Fields, and then in the Formula Fields I would like to grab just the Month of the above Date Field or the Week Number of the above Date Field. So more "Functions" than the current
                                                                                                            • File upload size limits

                                                                                                              I am designing a contact form in Zoho Creator with File upload facility. I am not sure where and how to set the following properties for the same: Allowed File Types Maximum Size of the Attachment Number of Attachments
                                                                                                            • Composite Services and Account Tracking

                                                                                                              I am looking to garner support/request the ability to make composite services. A quick search in the forums brings up multiple requests for this feature. I fail to see why an item is mandatory while services are optional. I also would like to see the
                                                                                                            • All operation codes getting Not applied in WO-TT22J1025WOR0471, SR-TT22J1025PRE0423,FOR VIN-W1K6G2AB2SL005130.

                                                                                                              Dear Support Team, Please refer attached screenshot. All operation codes getting not applied in work order. Request you to please check and update ASAP.
                                                                                                            • Customer Grouping

                                                                                                              Hi, how can I group multiple customers into single group. So that I can have idea of accounts receivables of all the customers in single group. Like if there are multiple subsidiaries of same company we have having a business with, and want to view the
                                                                                                            • Bank Receipt Catagorization

                                                                                                              Hi, how can I match a bank deposit to multiple customer's invoices ? For e.g. A single person paid to us on behalf of different five customers. I need to keep the separated invoices for each customer
                                                                                                            • "Performed changes in the query is not allowed due to following reason" when adding columns or reordering data

                                                                                                              I'm trying to make changes to a query but every time i try to save it i get this error message.  I'm not touching the data it's flagging.  All I've tried to do is reorder a couple of fields and add a new one.  Why won't it let me do this?  It's a core
                                                                                                            • Exclude Segment from Campaign Recipients

                                                                                                              I've created two Segments in order to separate Non-Marketing Contacts from Marketing Contacts. I'd like to send an Eblast to all Marketing contacts in my lists, but when I go to select Recipients, I have two options: 1. To Choose Lists to Send to; 2.
                                                                                                            • Reschedule Multiple/Mass Calls at Once

                                                                                                              When we go into a Call record, we have the option to "Reschedule Call." How can we select multiple Calls at once from the Activities tab and Reschedule them? The big use case for us: We have many leads that our reps are supposed to call on a daily basis.
                                                                                                            • Option to Empty Entire Mailbox or Folder in Zoho Mail

                                                                                                              Hello Zoho Mail Team, How are you? We would like to request an enhancement to Zoho Mail that would allow administrators and users to quickly clear out entire folders or mailboxes, including shared mailboxes. Current Limitation: At present, Zoho Mail only
                                                                                                            • Next Page