Hello Happy Day to All
i have a new challenge
i want to visible/invisible the button in 3 criteria
my challenge is how can i apply that in 50 button
Please see the attached file
Thank YOU in ADVANCE
Hello Happy Day to All
i have a new challenge
i want to visible/invisible the button in 3 criteria
my challenge is how can i apply that in 50 button
Please see the attached file
Thank YOU in ADVANCE
Hello blues_oo7,
This proved to be an interesting challenge. It seemed straightforward in the beginning but took some unexpected turns. User Defined Functions are tricky. When run in VB environment there are no restrictions. However, when used on a worksheet, things get interesting.
To make this hide an unhide the button, the UDF have to be made volatile. Rather than executing when needed, it is executed every time a formula on the worksheet is recalculated. This can slow you down.
The UDF takes four arguments: The Button Index Number, the column "F" cell, the column "D" cell, and $G$2. The UDF returns either TRUE or a Blank. The UDF formula is behind each button.
Here is the UDF code:
![]()
Function ShowHideButton(ByVal ButtonIndex As Integer, Cond1 As Range, Cond2 As Range, Cond3 As Range) Dim Btn As Excel.Shape Dim R As Long Dim Res As Boolean Application.Volatile Res = True Set Btn = ActiveSheet.Shapes("Button " & ButtonIndex) If Cond1.Value = "PAID" Or Cond2.Value >= 999 Then Res = False End If 'Ignore any link errors On Error Resume Next If Cond3 = 9999 Then Res = False On Error GoTo 0 If Res = True Then ShowHideButton = Res Else ShowHideButton = "" Btn.Visible = Res End Function
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Sir Leith Ross
Thanks for giving time on my challenge,
but the other button is not visible even the status is not PAID
sample cell I7,I10,I12,I15,I17 AND I20 the status is not PAID but the paid button is invisible
and i want the other button to be hide from I22 to I53 coz the D22 to D53 cell is blank
Thank you for your support and patience, i am totally noob in VBA
Thanks again,
blues_oo7
Hello blues_oo7,
What other buttons? I only saw "PAID" buttons on the worksheet.
I think this one-liner suffices:
![]()
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect([D:D, F:G], Target) Is Nothing Then Sheets(1).Buttons(Target.Row - 2).Visible = Not (Cells(Target.Row, 4) >= 999 Or Cells(Target.Row, 6) = "PAID" Or Cells(Target.Row, 7) = 9999) End Sub
sir the paid button on cell I7,I10,I12,I15,I17 AND I20
thank you
Sir snb thanks for the reply,
Sir not fit for my need, i need to hide button for three criteria
Please help
*BUMP*
Please Help
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks