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 5986749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:42:59+00:00 2026-05-22T22:42:59+00:00

I am trying to determine if a selected range is within a set area…

  • 0

I am trying to determine if a selected range is within a set area… This toggles Copy/Paste restrictions in the spreadsheet. I have figured it out, I think, but I’m getting a run-time error 6 (Overflow) if you select an entire row or column. This is what I’ve got..

Function BETWEENROWS(ByVal Selected As Range, ByVal Min As Double, ByVal Max As Double) As Boolean
    Dim LastRow As Integer
    LastRow = Selected.Row + Selected.Rows.Count - 1
    If BETWEEN(Min, Selected.Row, Max) = True And BETWEEN(Min, LastRow, Max) = True Then
        BETWEENROWS = True
    Else
        BETWEENROWS = False
    End If
End Function

There is one for columns BETWEENCOLUMNS as well and the function BETWEEN just returns True/False if a given number is between a min and max value.

This is working great, however, if an entire row/column is selected it’s throwing an error and I’m not too familiar with VBA and the only way that I know of bypassing the error is with On Error Resume Next but that seems like I’m putting a bandaid on it and would like to figure out how to fix it another way.

  • 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-05-22T22:43:00+00:00Added an answer on May 22, 2026 at 10:43 pm

    Your LastRow variable is not the correct type for a number as large as the max columns/rows of the spreadsheet. Change the type to Long:

    Dim LastRow As Long
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In trying to determine what area of a large query i have is causing
I'm trying to determine, based on the result of this call, if it was
I have been trying to determine a best case solution for registering a COM
I'm trying to determine what instances of sql server/sql express I have installed (either
Trying to determine best way to code this requirement : Need to insert rows
I'm trying to determine CPU usage of my PHP scripts. I just found this
I’m trying to determine a good way to handle the scenario below. I have
I'm trying to determine the currently selected portion of the date (or time) editor.
Not having much luck with this. I'm trying to determine if a var is
I'm trying determine if it's possible in C# to have a generic class that

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.