Transparent commandbutton that refuses to stay transparent??

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Code:
Private Sub cmdRosenbergElCampo_Click()

If cmdRosenbergElCampo.Caption = "EL-CAMPO" Then

Worksheets("Current").cmdRosenbergElCampo.Caption = "ROSENBERG"
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

Call Macro3

Else
   
Worksheets("Current").cmdRosenbergElCampo.Caption = "EL-CAMPO"
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

Call Macro4

End If
Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

End Sub


Thats the code for the commandbutton that under its properties on the worksheet its set to transparent ( and is transparent) but when its executed it changes to the standard grey color.

This is an activeX control, btw

Here is the other code (for Macro3 listed in the code above):

Code:
Sub Macro3()

    ' button for ROSENBERG EMPLOYEES
    
ActiveWindow.ScrollColumn = 1

Dim lCol As Long
    lCol = ActiveSheet.UsedRange.Columns.Count
    rCol = ActiveSheet.UsedRange.Rows.Count
    For Each Cell In Range(Cells(5, 6), Cells(5, lCol))

If Cell = "R" Then Columns(Cell.Column).Hidden = False Else Columns(Cell.Column).Hidden = True
Next

Range(Cells(1, 2), Cells(rCol, lCol)).Interior.Color = xlNone
Range(Cells(1, 2), Cells(rCol, lCol)).Font.Color = vbBlack
Range(Cells(1, 2), Cells(rCol, lCol)).Font.Bold = False
Range(Cells(1, 2), Cells(rCol, lCol)).Borders.Weight = xlThin

Range("B6").Font.Color = &HFF&
Range("B6").Font.Bold = True
Range("B6").Borders.Weight = xlMedium

Range("B2:B4").Font.Color = &HC000&
Range("B2:B4").Font.Bold = True
Range("B2:B4").Borders.Weight = xlThin

Worksheets("Current").cmdRosenbergElCampo.BackStyle = BackStyleTransparent

End Sub

Macro4 (the other event that is linked in the first code) is identical to macro3, btw


I went back in under both codes and added the "BackStyle = BackStyleTransparent" code which had no effect btw. :confused:

Is this a known issue, or do I just have something funky in my code that I'm just not seeing?

Thanks
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Not perfect but
Code:
Private Sub CommandButton1_Click()
Me.CommandButton1.TakeFocuson click= False
End Sub
will make it transparent once the cursor is moved off the button
Ignore the space between on & click, its only there to prevent the board turning it into ***
 
Last edited:
Upvote 0
Not perfect but
Code:
Private Sub CommandButton1_Click()
Me.CommandButton1.TakeFocuson click= False
End Sub
will make it transparent once the cursor is moved off the button
Ignore the space between on & click, its only there to prevent the board turning it into ***

Awesome! I was really thinking that it was a glitch in excel and I wasnt going to be able to 'fix' it. THat did the trick. No biggie that its black until you move the cursor... i can live with that.
icon14.png
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Awesome! I was really thinking that it was a glitch in excel and I wasnt going to be able to 'fix' it. THat did the trick. No biggie that its black until you move the cursor... i can live with that.
icon14.png

Or you could do this :
Code:
Private Sub CommandButton1_Click()
    CommandButton1.Visible = False
    CommandButton1.Visible = True
End Sub
 
Upvote 0
Just now saw this...

this is even better (doesnt temporarily make the button black until the cursor loses focus.) . THanks Jaafar.
icon14.png
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,957
Latest member
Hat4Life

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