How can i change this Worksheet_Change event to a sub for a commandbutton?

MisterExcellent

New Member
Joined
Apr 21, 2011
Messages
46
With this code you can show or hide the input messages on the basis of a dropdown(true/false).
I want to use this with a commandbutton and not a dropdown.
I look forward to your approaches.

Code:
'APJToolTips 
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim rng As Range
 Dim cel As Range
 If Target.Address = Me.Range("ShowUserMsg").Address Then
 Set rng = Me.Cells.SpecialCells(xlCellTypeAllValidation)
 For Each cel In rng.Cells
 With cel.Validation
 If .InputMessage <> "" Then .ShowInput = Target.Value
 End With
 Next cel
 End If
 End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

Maybe this

Insert a CommandButton assign the macro below to it

Code:
Sub testButton()
    Dim rng As Range, cel As Range
    
    Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)
    For Each cel In rng.Cells
        With cel.Validation
            .ShowInput = Not .ShowInput
        End With
    Next cel
 
End Sub

HTH

M.
 
Upvote 0
Hi,

Maybe this

Insert a CommandButton assign the macro below to it

Code:
Sub testButton()
    Dim rng As Range, cel As Range
    
    Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeAllValidation)
    For Each cel In rng.Cells
        With cel.Validation
            .ShowInput = Not .ShowInput
        End With
    Next cel
 
End Sub
HTH

M.

Obrigado Marcelo!

I have another question.
I'd be delighted if you could conform this code as follows:

How would you change this code to show/not show the inputmsg for the whole active sheet (or the whole workbook) and not just specialcells?
 
Upvote 0
Obrigado Marcelo!

I have another question.
I'd be delighted if you could conform this code as follows:

How would you change this code to show/not show the inputmsg for the whole active sheet (or the whole workbook) and not just specialcells?

You are welcome!
(de nada! :) )

I am not sure if i understood what you mean by "not just special cells", since you can have (or not) input messages only in cells where data-validation was applied. As far as i know...

M.
 
Upvote 0
You are welcome!
(de nada! :) )

I am not sure if i understood what you mean by "not just special cells", since you can have (or not) input messages only in cells where data-validation was applied. As far as i know...

M.

Mais uma vez, agradeço :)

In this Code i have to name the ranges with the Input Messages (Special Cells).
But i don't want to select the cells to be named.

Is it possible to use the ActiveSheet and not just ActiveSheet.Cells.NamedRange?

Até a próxima Marcelo!
(Until next time!)
 
Upvote 0
Who else knows another possibility for hiding/showing InputMessages in an ActiveSheet without selecting the cells to be named?
 
Upvote 0
Re: Help me please :(

I'm not sure what you are after.

If you want a message to appear every time a user selects any cell on a worksheet (same message for every cell) a SelctionChange event would me easier to manage than Validation (=TRUE) on every cell.
 
Upvote 0
Re: Help me please :(

I'm not sure what you are after.

If you want a message to appear every time a user selects any cell on a worksheet (same message for every cell) a SelctionChange event would me easier to manage than Validation (=TRUE) on every cell.

Hi Mike,
thank you very much.
How would you do this?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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