Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:23:47+00:00 2026-06-18T14:23:47+00:00

I have a Worksheet_Change event, currently at the Sheet Module Level . The problem

  • 0

I have a Worksheet_Change event, currently at the Sheet Module Level. The problem is that I want to be able to clear this sheet at times. However, when I clear my sheet I get an overflow:

Private Sub Worksheet_Change(ByVal Target As Range)
    'This is the line causing the problem because clearing the whole sheet causes the count to be massive
    If Target.Count = 1 Then
        If Target = Range("A4") Then
            If InStr(LCase(Target.Value), "loaded") <> 0 Then
                Range("A5").FormulaArray = "=My_Function(R[-1]C)"
            End If
        End If
    End If
End Sub

I am trying to achieve the following:

I press a button and the sheet is cleared (clears existing array formula data), I then paste in a formula to the sheet and call the formula. The formula returns data back to the excel cache and changes the cell containing this formula (A4) to a string saying “loaded”. When I detect a cell change with value “loaded” I then do the equivalent on Ctrl + Shift + Enter on an array formula function below, to display the data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:23:49+00:00Added an answer on June 18, 2026 at 2:23 pm

    I believe you are using xl2007+?

    The Target.Cells.Count is a Long value and hence when you select the entire worksheet the .Count is too small to hold the result.

    Replace line

    If Target.Count = 1 Then   
    

    with

    If Target.Cells.CountLarge = 1 Then
    

    You might also want to see this since you are using Worksheet_Change

    EDIT:

    Two other things

    1)

    You can also replace this line

    If Target = Range("A4") Then
    

    with

    If Not Intersect(Target, Range("A4")) Is Nothing Then
    

    2)

    This line

    If InStr(LCase(Target.Value), "loaded") <> 0 Then
    

    can also be written as

    If InStr(1, Target.Value, "loaded", vbTextCompare) Then
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have this code : Private Sub Worksheet_Change(ByVal Target As Range) Dim lastrow
I currently have this code Private Sub Worksheet_Change(ByVal Target As Range) WorksheetChanged(Target, Range(AB3).CurrentRegion, Range(B18:B19))
I'm using Excel VBA and have a worksheet_change event like so: Private Sub Worksheet_Change(ByVal
I have three macros in my workbook that work fine. However, when I protect
I have an excel tool that was made by someone before me. However, when
This is a universal log system, that a few people here and myself have
I have this code and i want do filter the autofill results by two
I have defined a Worksheet_Change sub on a sheet. It works fine. I just
I have a macro that runs when any cell is changed, and I want
I currently have this code: Option Explicit Private Declare Function sndPlaySound32 Lib winmm.dll _

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.