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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:14:13+00:00 2026-06-17T02:14:13+00:00

In my Main procedure I want to write a quick if-statement which checks whether

  • 0

In my Main procedure I want to write a quick if-statement which checks whether the user has made a valid input (user chooses number of project from list of data, see attached screenshot). For that I am checking whether the project number is not part of the list of projects. If that is true, an error message is displayed; if not then a number of other procedures are called.

For some reason though I get error 2015 when I run it, which means that the if-statement is always true, even on correct user entries. Can someone help me understand the error please?

  • The project number input is a named cell called “IdSelect” and is on a sheet called “Invoice”
  • The data against which this input is checked is on a sheet called “Input”
  • The data is stored in column B and called “ProjectList”

Code below (note: I have tried pasting it 5 times but the formatting still won’t work this time for some reason – any idea what that could be? The code is properly formatted. Sorry for the messy display; if anyone can tell me what that problem might I would be very grateful!)

Sub Main()
    'Turn off screen updating
    Application.ScreenUpdating = False
    'Define variable for currently active cell to reactivate it afterwards
    Dim OldActiveSheet As Object
    Dim OldActiveCell As Object
    Dim i As Integer
    Dim ProjectList As Range
    Set OldActiveSheet = ActiveSheet
    Set OldActiveCell = ActiveCell
    'If-statement to check whether project number is valid or not
    Worksheets("Invoice").Activate
    'Print to Immediate Window to check value - remove later
    Debug.Print Range("IdSelect").Value
    If IsError(Application.Match(Range("IdSelect").Value, "ProjectList", 0)) Then
        'Print to Immediate Window to check value - remove later
        Debug.Print Application.Match(Range("IdSelect").Value, Worksheets("Input").Range("ProjectList"), 0)
        MsgBox "Invalid Choice: Project with this number does not exist!"
        Exit Sub
    Else
        'Call procedures to execute
        Call SortData
        Call Count_Line_Items
        Call Count_Total_Rows
        Call Write_Services(ServCnt)
        Call Write_Expenses(ExpCnt)
    End If
    'Reactivate previous active cell
    OldActiveSheet.Activate
    OldActiveCell.Activate
End Sub

Screenshot from “Input” sheet:

enter image description here

  • 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-17T02:14:15+00:00Added an answer on June 17, 2026 at 2:14 am

    The way you refer to range is rather odd.. because you missed out range reference. Oddly enoughbthat you do it correct on the next line at
    Debug.Print Application.Match(Range("IdSelect").Value, Worksheets("Input").Range("ProjectList"), 0)

    So try this please: (it take me 100 years to format my own post on mobile…..). Make sure to use explicit reference as shown in my sample code below. Set your sheets accordingly.

    Dim ws as Worksheet
    Set ws = Sheets(1)
    
     IsError(Application.Match(ws.Range("IdSelect").Value, ws.Range("ProjectList"), 0)) Then 
    

    And here is for you to read on for error handling on on match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a funcion or procedure that can be used in the
I have made a procedure in PL/SQL which inserts data from one table to
in Delphi the procedure write can handle: write(TF,st1) and write(TF,st1,st2,st3,st4); I want to declare
I want to ask the user to input a password. As the password is
I want to finally get to know how to write an application which uses
I'm using an error handler on my main calling procedure and letting the other
Main thread of application is doing some work. There also exists a timer, which
main.c (with all the headers like stdio, stdlib, etc): int main() { int input;
I need to detect a procedure from a click event has finished without delaying
I need to write a procedure in assembler, that calculates the value of a

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.