Hi,
Can someone tell me what to put in this code so that if a user selects 0 (Black) then make the font white (0) as my default colour is black on my Excel spreadsheet. -
Private Type CHOOSECOLOUR
-
lStructSize As Long
-
hwndOwner As Long
-
Hinstance As Long
-
rgbResult As Long
-
lpCustColors As String
-
flags As Long
-
lCustData As Long
-
lpfnHook As Long
-
lpTemplateName As String
-
End Type
-
-
Declare Function ChooseColorA _
-
Lib "Comdlg32" ( _
-
lpChooseColor As CHOOSECOLOUR) _
-
As Long
-
Declare Function FindWindowA _
-
Lib "User32" ( _
-
ByVal lpClassName As Any, _
-
ByVal lpWindowName As String) _
-
As Long
-
-
Function SelectColour(Code_RGB) As Boolean
-
Dim CColor As CHOOSECOLOUR
-
Dim CustColors As String * 16
-
With CColor
-
.lStructSize = 36
-
.hwndOwner = FindWindowA(0&, Application.Caption)
-
.lpCustColors = CustColors
-
.flags = 2
-
End With
-
If ChooseColorA(CColor) = 0 Then Exit Function
-
Code_RGB = CColor.rgbResult
-
SelectColour = True
-
End Function
-
-
Public Function RGBRed(RGBCol As Long) As Integer
-
'// Return the Red component from an RGB Color
-
RGBRed = RGBCol And &HFF
-
End Function
-
-
Public Function RGBGreen(RGBCol As Long) As Integer
-
'// Return the Green component from an RGB Colour
-
RGBGreen = ((RGBCol And &H100FF00) / &H100)
-
End Function
-
-
Public Function RGBBlue(RGBCol As Long) As Integer
-
'// Return the Blue component from an RGB Colour
-
RGBBlue = (RGBCol And &HFF0000) / &H10000
-
End Function
-
-
Sub Theme()
-
-
If Sheets("Tasks").ProtectContents = True Then
-
Sheets("Tasks").Unprotect ("*******")
-
End If
-
If Sheets("Stats").ProtectContents = True Then
-
Sheets("Stats").Unprotect ("*******")
-
End If
-
If Sheets("User Guides").ProtectContents = True Then
-
Sheets("User Guides").Unprotect ("*******")
-
End If
-
'If Sheets("Stats").ProtectContents = True Then
-
Sheets("Stats").Unprotect ("*******")
-
'End If
-
-
MsgBox "Please select a new heading colour using the popup colour selector and then press OK.", 64, "Change your heading colour."
-
Dim Code_RGB As Long
-
Dim myRange1 As Range, myRange2 As Range, myRange3 As Range, myRange4 As Range, myRange5 As Range, myRange6 As Range, myRange7 As Range
-
If Not SelectColour(Code_RGB) Then Exit Sub
-
Set myRange1 = ActiveSheet.Range("A4,A5,A6,B6,C1,C6,D6,E1,E6,F1,F6,G1,G6,H1,H2,H3,H4,H5,H6,I6,J6,K2,K3,K4,K5,K6,L6,M6,N2,N3,N4,N5,N6,O6,P6,Q1,Q2,Q4,Q5,Q6,R1,R6,S1,S6,T6,U6,V6")
-
Set myRange2 = Worksheets("Stats").Range("A2,A12,B2,B3,B4,B5,B7,B12,C7,C12,D7,D12,E7,E8,E9,E10,E11,E12,F12,(G12:G214)")
-
Set myRange7 = Worksheets("User Guides").Range("A1,A2,B2")
-
If ActiveSheet.ProtectContents = True Then
-
ActiveSheet.Unprotect ("*******")
-
End If
-
myRange1.Interior.Color = Code_RGB
-
myRange2.Interior.Color = Code_RGB
-
-
Set myRange1 = Nothing
-
Set myRange2 = Nothing
-
Set myRange6 = Nothing
-
Set myRange7 = Nothing
-
-
If Sheets("Tasks").ProtectContents = False Then
-
Sheets("Tasks").Protect ("*******")
-
End If
-
If Sheets("Stats").ProtectContents = False Then
-
Sheets("Stats").Protect ("*******")
-
End If
-
If Sheets("User Guides").ProtectContents = False Then
-
Sheets("User Guides").Protect ("*******")
-
End If
-
'If Sheets("Stats").ProtectContents = True Then
-
'Sheets("Stats").Unprotect ("*******")
-
'End If
-
-
ActiveSheet.Protect ("*******")
-
-
End Sub
-
Hope someone can help me on this little problem as in the test people were choosing black, cuz it's cool..
0 1578 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Keith |
last post by:
I have downloaded some sample code from the net to display a calendar etc.
The code is below.
How can I modify this code so that when called in a popup window and a date
is clicked, that date...
|
by: Louise |
last post by:
Hi
I have written an HTML pages which does not have any colour specifying
tags as far I know. When I view this in an Microsoft internet
explorer browser it appears with a white background and...
|
by: Viken Karaguesian |
last post by:
Hello all,
It stinks being a newbie! One thing that I'm not sure about with CSS
is: where is the "proper" place to put font attibutes? This has me a
little confused. Take the below style sheet...
|
by: netsurfer |
last post by:
Hi:
I am working on a project and need assistance, and would really
appreciate any feedback on it.
First part I'm banging my head against the wall on is about the amounts
of the Amount fields...
|
by: Annick |
last post by:
I would like to change the format of a cell depended on the value of
the data.
I wrote the following script, which works fine.
.. . .
Function function_ChangeFormat(ByVal value_01)
Dim...
|
by: Novice Computer User |
last post by:
Hi. Can somebody PLEASE help. Here is a .php script. Right now, the
minimum amount of time (i.e. duration) allowed is 1 month. However, I
want to be able to reduce the minimum amount of time to...
|
by: xformer |
last post by:
Hello everybody,
today I was working on a web site when I found a strange effect.
Take the following html document:
----begin----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
|
by: Jonas Smithson |
last post by:
In his book "CSS: The Definitive Guide" 2nd edition (pgs. 116-117), Eric
Meyer has an interesting discussion about "font-size-adjust" that was
evidently dropped in CSS 2.1 due to browser...
|
by: CSharper |
last post by:
Is it possible to selectivly change the color of an item in text. I
saw ForeColor option, but it changes the color of all the items. If it
is not possible, is there any other control list listbox...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |