VBA Enable ribbon button on selection of a column

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
525
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Hi I am trying to enable a ribbon button if a column is selected, I know I need to use the on selection change event but not sure how I do this, Can someone help please
 

Excel Facts

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

I have no idea how to do it, but could you try recording a macro to achieve what you want and then jump into the code to see what it says? Worth a try i reckon.

Best regards
manc
 
Upvote 0
Hi manc, Unfortunately recording a macro won't help with this. I have found some code though but just need help with enabling the ribbon button, see code below

Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim Rng As Range
        Set Rng = Intersect(Target, Me.Selection)
            If Rng.Columns.Count = 1 Then
                ' Enable Ribbon Button
            Else
                ' Do nothing
            End If
    End Sub
 
Last edited:
Upvote 0
Hi manc, Thanks but this doesn't help unfortunately as it doesn't show an example of selection Change Event.
 
Upvote 0
Apologies, i did say i didn't what i was talking about.

I thought however that with a bit of tweaking, one of the examples on there shows onAction Event - thought that might be the same.
One last go - try here http://www.rondebruin.nl/win/section2.htm

Good luck finding your answer.
Beam me up Scottie - i'm out.

Best regards
manc
 
Last edited:
Upvote 0
Thanks for your help, however still no luck I'm afraid. I have been looking all over for what I need but to no avail, may have to give up for now and come back to it another time, I know I have the cake but just need the cherry on top so to speak, Anyway Thanks again. Can anyone else help?
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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