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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:09:26+00:00 2026-06-05T17:09:26+00:00

When i click a button on my worksheet the below event is called. I

  • 0

When i click a button on my worksheet the below event is called.

I get the error ‘Type mismatch’

I suspect I need another if statement to stop the original IF being evaluated if the event is due to a button being pressed?

Private Sub Worksheet_Change(ByVal Target As Range)

    If Target = Range("D4") Then   'Error is here

    End If

End Sub
  • 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-05T17:09:29+00:00Added an answer on June 5, 2026 at 5:09 pm

    This

    If Target = Range("D4") Then
    

    is equivalent to this

    If Target.Value = Range("D4").Value Then
    

    which clearly is not what you want. You will probably get the error you describe if Target.Value happens not to be of the same type as Range("D4").Value.

    What you want is this:

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

    EDIT I just managed to reproduce your error. It occurs if the Target range is of a different size than Range("D4") i.e. spans more than one cell. As @Dick Kusleiska notes, it also occurs if one of the two is an error value. Maybe it’s triggered by other things as well, I don’t know. Anyhow, the point is, your If condition is wrong!

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

Sidebar

Related Questions

i need to get multiple circle images when i click button. and i done
In button click event I am writing this code.(code behind).I know button click event
The code below is supposed to get the next record when a button is
I'm calling the following method from a button click event to export a datatable
I need to know if it's possible to call the Click of a button
I have some Backbone.js code that bind a click event to a button, and
I am easily changing the color of polyline on click button my code below,
hi i am doing one app here.user click button once means in another activity
I made a camera layout where two buttons existed.A click button and a share
I am trying to use some action when I click button in navigation controller.

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.