krunal123

Board Regular
Joined
Jun 26, 2020
Messages
169
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Query.png



When I Click cell C8, I should see the command button shown in E8 not otherwise via vba coding.

i was follow this code but not working pleased help me :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
Me.Shapes("CommandButton1").Visible = True
Else
Me.Shapes("CommandButton1").Visible = False
End If
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi there

Try the below...

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = True
Else
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = False
End If
End Sub
 
Upvote 0
Hi there

Try the below...

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = True
Else
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = False
End If
End Sub
1686210461606.png


Error Showing Sir , pleased Help
 
Upvote 0
You have two Worksheet_Change Events...You can only have one... so basically you need too:

In your original code replace
VBA Code:
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
Me.Shapes("CommandButton1").Visible = True
Else
Me.Shapes("CommandButton1").Visible = False
End If
with
VBA Code:
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = True
Else
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = False
End If
 
Upvote 0
You have two Worksheet_Change Events...You can only have one... so basically you need too:

In your original code replace
VBA Code:
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
Me.Shapes("CommandButton1").Visible = True
Else
Me.Shapes("CommandButton1").Visible = False
End If
with
VBA Code:
If Not Intersect(Target, Me.Range("C8")) Is Nothing Then
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = True
Else
ActiveSheet.Shapes.Range(Array("CommandButton1")).Visible = False
End If
i was i was tired is Not working Sir
 
Upvote 0
Is the command button of type Button(Form Control) or Command Button(ActiveX Control) or is it a shape that you draw yourself? Please provide full code of WorkSheet Selection Change
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

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