LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,886
Default How to get buttons on floating control to pick up colour

Hi

I have created a control with 8 command buttons, for the user to be able
to quickly format cells according to the background colour and font
colour of the button clicked.

I want to be able to pick up the colours and a caption from a setup
sheet, but it isn't working.
The first 4 buttons are selecting the colours set for the last 4, and
the last 4 are left unaltered.
No captions are being picked up to display on each button.

Any clues as to what I am doing wrong - I have been going round in
circles all morning, and can't see the error.

Private Sub Userform_Initialize()
On Error Resume Next
Dim ctrl As Control, btnColors As Long, btn As Long, btnColors2 As
Long, btn2 As Long
Dim vaFore As Variant, vaBack As Variant, vaCapt As Variant
Dim btncaption As String, btncount As Long, i as long

vaBack = Sheets("Colors").Range("E4:E11").Value
vaFore = Sheets("Colors").Range("F4:F11").Value
vacapt = Sheets("Colors").Range("H4:H11").Value
i = 0
btncount = Sheets("Colors").Range("E1").Value 'this counts the
number of cells with values in E4:E11

For Each ctrl In frmcolours2.Controls
If ctrl.Tag = "Color Button" Then
btn = i
btnColors = vaBack(i, 1): btnColors2 = vaFore(i,
1):btnCaption = vaCapt(i,1)
ReDim Preserve Buttons(1 To 8)
Set Buttons(btn).ColorButtons = ctrl
Buttons(btn).ColorButtons.BackColor _
= ThisWorkbook.Colors(btnColors)
Buttons(btn).ColorButtons.ForeColor _
= ThisWorkbook.Colors(btnColors2)
' what need to be inserted here to write the Caption to the
button?

End If
i = i + 1
Next ctrl
End Sub



--
Regards

Roger Govier



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colour formatting using command buttons and comparing data. Luke Excel Discussion (Misc queries) 4 January 19th 07 08:19 PM
My Command Buttons keep floating on the sheet??? alondon Excel Programming 2 November 28th 04 12:35 AM
Control Buttons to VBA JasonSelf[_11_] Excel Programming 1 May 13th 04 08:15 PM
Control Buttons vs. Command Buttons Robert Gibson Excel Programming 1 October 13th 03 04:33 PM
Floating control box mcm Excel Programming 7 August 29th 03 04:06 PM


All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"