Cells checking for changes error

grabrail

Board Regular
Joined
Sep 6, 2010
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a bit of code that monitors specific cells for changes, and if the entry of DF is entered, a form opens up for them to fill in some details.

I also have a button they can press that can set those cells to "N/A" if the data for the particular check they are doing isnt applicable

When I click the button to make all the cells required as N/A, including the cells being monitored for DF, I get a type mismatch error and the line of code below that include "DF" is highlighted. Available options for these cells are DF, NDF and N/A, why would i get the type mismatch error when the value of the cell is being set to N/A?

VBA Code:
  ElseIf Not Intersect(Target, Range("M43:M48, M51:M54, M56:m59")) Is Nothing Then
        
            If Target.Value = "DF" Then
            
                tyres.Show
                
            End If
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Most likely the problem is that when you press that other button to enter the "N/A" values it is triggering this code and when it gets to the problem line, it cannot do Target.Value because Target has 14 values.

A couple of possible solutions
1. In your "N/A" button code, set Application.EnableEvents = False at the start (& reset to True at the end) so that this code does not get triggered when you press the button
2. In this code at the start check if Target.Count > 1 and if so skip this code

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Solution
Most likely the problem is that when you press that other button to enter the "N/A" values it is triggering this code and when it gets to the problem line, it cannot do Target.Value because Target has 14 values.

A couple of possible solutions
1. In your "N/A" button code, set Application.EnableEvents = False at the start (& reset to True at the end) so that this code does not get triggered when you press the button
2. In this code at the start check if Target.Count > 1 and if so skip this code

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Perfect thank you, I used option 1 and does the trick.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

.. and don't forget the last paragraph in my previous post. ;)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top