Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

couleur onglet

8 réponses
Avatar
vince
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou autre ?
Je n'ai rien trouvé dans l'aide, ni dans les forums et sites ...

Merci de votre réponse

8 réponses

Avatar
Patrick Fredin
Bonjour,

Il y a un bon truc dans Excel... C'est l'enregistreur de macros. Et voila ce
que me propose Excel :

Sheets("Feuille").Tab.ColorIndex = 3

--
Patrick

"vince" wrote in message
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou autre ?
Je n'ai rien trouvé dans l'aide, ni dans les forums et sites ...

Merci de votre réponse




Avatar
JpPradier
Il faut préciser que c'est à partir d'excel 2002 .

j-p
Avatar
Clément Marcotte
Bonjour,

Il n'y a rien à faire pour toutes les versions avant Excel 2002.


"vince" a écrit dans le message de
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou autre
?

Je n'ai rien trouvé dans l'aide, ni dans les forums et sites ...

Merci de votre réponse




Avatar
Jacky
Ah..., j'me disais aussi...
;o))
JJ

"JpPradier" a écrit dans le message
de news:%
Il faut préciser que c'est à partir d'excel 2002 .

j-p



Avatar
GD
Bonsour® Clément
;o))))
rien à faire ???? c'est vite dit !!!

Ivan F Moala ( MVP , CellMaster) a toutefois émis :
So if someone says it can't be done, show them this :-)

'Changing the colour of the Tab
'==================== '// Routine goes in the ThisWorkBook Object
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ChangeTab_Colour
End Sub
'// Routine goes into a Standard Module
Option Explicit
'// Routine to change the colour of the Spreadsheet Tabs
'// API's for System Colours
Private Declare Function GetSysColor Lib "user32" ( ByVal nIndex As Long)
As Long
Private Declare Function SetSysColors Lib "user32" ( ByVal nChanges As Long,
_
lpSysColor As Long, _
lpColorValues As Long) As Long
'// Define Colour Constant
Private Const COLOR_WINDOW = 5
Sub ChangeTab_Colour()
Dim Kolor As Long
Dim CurKolor As Long
Dim R As Integer, G As Integer, B As Integer
'// Initialize random-number generator.
Randomize
'// Generate random value between 0 and 255.
R = Int(255 * Rnd)
G = Int(255 * Rnd)
B = Int(255 * Rnd)
'// Try these if you want Basic Colours
'// ============================================== '// Black 0 0 0 || Blue 0 0 255
'// Green 0 255 0 || Cyan 0 255 255
'// Red 255 0 0 || Magenta 255 0 255
'// Yellow 255 255 0 || White 255 255 255
'// ============================================== CurKolor = GetSysColor(COLOR_WINDOW)
With Application
.ScreenUpdating = False
'// color it Randomly
Kolor = SetSysColors(1, COLOR_WINDOW, RGB(R, G, B))
ShSet
.ScreenUpdating = True
MsgBox "Tab colour has changed!", vbInformation + vbSystemModal, "Tab
Colour Hack "
.ScreenUpdating = False
ShReset
'// Restore to Default
Kolor = SetSysColors(1, COLOR_WINDOW, CurKolor)
.ScreenUpdating = True
End With
End Sub

Sub ShSet()
Dim x As Double
Cells.Select
With Selection
.Interior.ColorIndex = 2
.Interior.Pattern = xlSolid
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With

For x = 7 To 12
With Selection.Borders(x)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next
[A1].Select
End Sub

Sub ShReset()
Cells.Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
[A1].Select
End Sub

http://www.xcelfiles.com/Excel01_02.html

même si ce code est un "hack" ;o)))
le site regorge d'astuces hautement dignes d'utilisation.
;o)))
@+



Clément Marcotte wrote:
Bonjour,

Il n'y a rien à faire pour toutes les versions avant Excel 2002.


"vince" a écrit dans le message de
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou autre ?
Je n'ai rien trouvé dans l'aide, ni dans les forums et sites ...

Merci de votre réponse




Avatar
vince
Bonsoir
Bon, je vais essayer d'adapter ça. Comme je n'ai pas excel 2002, c'est la
seule alternative
Merci a tous pour vos infos

"GD" a écrit dans le message de news:
eYxp#
Bonsour® Clément
;o))))
rien à faire ???? c'est vite dit !!!

Ivan F Moala ( MVP , CellMaster) a toutefois émis :
So if someone says it can't be done, show them this :-)

'Changing the colour of the Tab
'==================== > '// Routine goes in the ThisWorkBook Object
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ChangeTab_Colour
End Sub
'// Routine goes into a Standard Module
Option Explicit
'// Routine to change the colour of the Spreadsheet Tabs
'// API's for System Colours
Private Declare Function GetSysColor Lib "user32" ( ByVal nIndex As Long)
As Long
Private Declare Function SetSysColors Lib "user32" ( ByVal nChanges As
Long,

_
lpSysColor As Long, _
lpColorValues As Long) As Long
'// Define Colour Constant
Private Const COLOR_WINDOW = 5
Sub ChangeTab_Colour()
Dim Kolor As Long
Dim CurKolor As Long
Dim R As Integer, G As Integer, B As Integer
'// Initialize random-number generator.
Randomize
'// Generate random value between 0 and 255.
R = Int(255 * Rnd)
G = Int(255 * Rnd)
B = Int(255 * Rnd)
'// Try these if you want Basic Colours
'// ============================================== > '// Black 0 0 0 || Blue 0 0 255
'// Green 0 255 0 || Cyan 0 255 255
'// Red 255 0 0 || Magenta 255 0 255
'// Yellow 255 255 0 || White 255 255 255
'// ============================================== > CurKolor = GetSysColor(COLOR_WINDOW)
With Application
.ScreenUpdating = False
'// color it Randomly
Kolor = SetSysColors(1, COLOR_WINDOW, RGB(R, G, B))
ShSet
.ScreenUpdating = True
MsgBox "Tab colour has changed!", vbInformation + vbSystemModal, "Tab
Colour Hack "
.ScreenUpdating = False
ShReset
'// Restore to Default
Kolor = SetSysColors(1, COLOR_WINDOW, CurKolor)
.ScreenUpdating = True
End With
End Sub

Sub ShSet()
Dim x As Double
Cells.Select
With Selection
.Interior.ColorIndex = 2
.Interior.Pattern = xlSolid
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With

For x = 7 To 12
With Selection.Borders(x)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next
[A1].Select
End Sub

Sub ShReset()
Cells.Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
[A1].Select
End Sub

http://www.xcelfiles.com/Excel01_02.html

même si ce code est un "hack" ;o)))
le site regorge d'astuces hautement dignes d'utilisation.
;o)))
@+



Clément Marcotte wrote:
Bonjour,

Il n'y a rien à faire pour toutes les versions avant Excel 2002.


"vince" a écrit dans le message de
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou autre ?
Je n'ai rien trouvé dans l'aide, ni dans les forums et sites ...

Merci de votre réponse








Avatar
GD
Bonsour® Vince ,
Hélas et malgré la souriette destinée à Clément..
je doute fort que tu ne puisses parvenir à tes fins...
Bien que ce code soit l'oeuvre d'un guru EXCEL et comme précisé dans le code
ainsi que sur le Site ,

"Tab Colour Hack "

ce n'est q'une illusion...

en dehors de EXCEL 2002 et +
la mise en couleur des onglets est impossible de façon réellement
utilisable....

Désolé de t'avoir fait naïvement espérer une solution :-((
@+

wrote:
Bonsoir
Bon, je vais essayer d'adapter ça. Comme je n'ai pas excel 2002,
c'est la seule alternative
Merci a tous pour vos infos

"GD" a écrit dans le message de news:
eYxp#
Bonsour® Clément
;o))))
rien à faire ???? c'est vite dit !!!

Ivan F Moala ( MVP , CellMaster) a toutefois émis :
So if someone says it can't be done, show them this :-)

'Changing the colour of the Tab
'==================== >> '// Routine goes in the ThisWorkBook Object
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ChangeTab_Colour
End Sub
'// Routine goes into a Standard Module
Option Explicit
'// Routine to change the colour of the Spreadsheet Tabs
'// API's for System Colours
Private Declare Function GetSysColor Lib "user32" ( ByVal nIndex As
Long) As Long
Private Declare Function SetSysColors Lib "user32" ( ByVal nChanges
As Long, _
lpSysColor As Long, _
lpColorValues As Long) As Long
'// Define Colour Constant
Private Const COLOR_WINDOW = 5
Sub ChangeTab_Colour()
Dim Kolor As Long
Dim CurKolor As Long
Dim R As Integer, G As Integer, B As Integer
'// Initialize random-number generator.
Randomize
'// Generate random value between 0 and 255.
R = Int(255 * Rnd)
G = Int(255 * Rnd)
B = Int(255 * Rnd)
'// Try these if you want Basic Colours
'// ============================================== >> '// Black 0 0 0 || Blue 0 0 255
'// Green 0 255 0 || Cyan 0 255 255
'// Red 255 0 0 || Magenta 255 0 255
'// Yellow 255 255 0 || White 255 255 255
'// ============================================== >> CurKolor = GetSysColor(COLOR_WINDOW)
With Application
.ScreenUpdating = False
'// color it Randomly
Kolor = SetSysColors(1, COLOR_WINDOW, RGB(R, G, B))
ShSet
.ScreenUpdating = True
MsgBox "Tab colour has changed!", vbInformation + vbSystemModal,
"Tab Colour Hack "
.ScreenUpdating = False
ShReset
'// Restore to Default
Kolor = SetSysColors(1, COLOR_WINDOW, CurKolor)
.ScreenUpdating = True
End With
End Sub

Sub ShSet()
Dim x As Double
Cells.Select
With Selection
.Interior.ColorIndex = 2
.Interior.Pattern = xlSolid
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With

For x = 7 To 12
With Selection.Borders(x)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next
[A1].Select
End Sub

Sub ShReset()
Cells.Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
[A1].Select
End Sub

http://www.xcelfiles.com/Excel01_02.html

même si ce code est un "hack" ;o)))
le site regorge d'astuces hautement dignes d'utilisation.
;o)))
@+



Clément Marcotte wrote:
Bonjour,

Il n'y a rien à faire pour toutes les versions avant Excel 2002.


"vince" a écrit dans le message de
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou
autre ? Je n'ai rien trouvé dans l'aide, ni dans les forums et
sites ...

Merci de votre réponse








Avatar
vince
Ok, y a pas de mal ! D'autant que j'avais pas commencé à me prendre la tête
sur ce bout de code :)
En tout cas, merci pour les recherches

"GD" a écrit dans le message de news:

Bonsour® Vince ,
Hélas et malgré la souriette destinée à Clément..
je doute fort que tu ne puisses parvenir à tes fins...
Bien que ce code soit l'oeuvre d'un guru EXCEL et comme précisé dans le
code

ainsi que sur le Site ,

"Tab Colour Hack "

ce n'est q'une illusion...

en dehors de EXCEL 2002 et +
la mise en couleur des onglets est impossible de façon réellement
utilisable....

Désolé de t'avoir fait naïvement espérer une solution :-((
@+

wrote:
Bonsoir
Bon, je vais essayer d'adapter ça. Comme je n'ai pas excel 2002,
c'est la seule alternative
Merci a tous pour vos infos

"GD" a écrit dans le message de news:
eYxp#
Bonsour® Clément
;o))))
rien à faire ???? c'est vite dit !!!

Ivan F Moala ( MVP , CellMaster) a toutefois émis :
So if someone says it can't be done, show them this :-)

'Changing the colour of the Tab
'==================== > >> '// Routine goes in the ThisWorkBook Object
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
ChangeTab_Colour
End Sub
'// Routine goes into a Standard Module
Option Explicit
'// Routine to change the colour of the Spreadsheet Tabs
'// API's for System Colours
Private Declare Function GetSysColor Lib "user32" ( ByVal nIndex As
Long) As Long
Private Declare Function SetSysColors Lib "user32" ( ByVal nChanges
As Long, _
lpSysColor As Long, _
lpColorValues As Long) As Long
'// Define Colour Constant
Private Const COLOR_WINDOW = 5
Sub ChangeTab_Colour()
Dim Kolor As Long
Dim CurKolor As Long
Dim R As Integer, G As Integer, B As Integer
'// Initialize random-number generator.
Randomize
'// Generate random value between 0 and 255.
R = Int(255 * Rnd)
G = Int(255 * Rnd)
B = Int(255 * Rnd)
'// Try these if you want Basic Colours
'// ============================================== > >> '// Black 0 0 0 || Blue 0 0 255
'// Green 0 255 0 || Cyan 0 255 255
'// Red 255 0 0 || Magenta 255 0 255
'// Yellow 255 255 0 || White 255 255 255
'// ============================================== > >> CurKolor = GetSysColor(COLOR_WINDOW)
With Application
.ScreenUpdating = False
'// color it Randomly
Kolor = SetSysColors(1, COLOR_WINDOW, RGB(R, G, B))
ShSet
.ScreenUpdating = True
MsgBox "Tab colour has changed!", vbInformation + vbSystemModal,
"Tab Colour Hack "
.ScreenUpdating = False
ShReset
'// Restore to Default
Kolor = SetSysColors(1, COLOR_WINDOW, CurKolor)
.ScreenUpdating = True
End With
End Sub

Sub ShSet()
Dim x As Double
Cells.Select
With Selection
.Interior.ColorIndex = 2
.Interior.Pattern = xlSolid
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
End With

For x = 7 To 12
With Selection.Borders(x)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 15
End With
Next
[A1].Select
End Sub

Sub ShReset()
Cells.Select
With Selection
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlNone
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
.Interior.ColorIndex = xlNone
End With
[A1].Select
End Sub

http://www.xcelfiles.com/Excel01_02.html

même si ce code est un "hack" ;o)))
le site regorge d'astuces hautement dignes d'utilisation.
;o)))
@+



Clément Marcotte wrote:
Bonjour,

Il n'y a rien à faire pour toutes les versions avant Excel 2002.


"vince" a écrit dans le message de
news:41c0a2f7$0$11654$
Bonjour a tous,
y a t-il moyen de modifier la couleur d'un onglet, par VBA ou
autre ? Je n'ai rien trouvé dans l'aide, ni dans les forums et
sites ...

Merci de votre réponse