Jump to content

Diferenciar cor e tipo dos binários


Pennafortt

Recommended Posts

Boas

. O código funciona bem, queria apenas mudar a maneira (cor) como é mostrado os binários na tabela A3:G10. Na versão original, zeros (0) e uns (1) tem fonte normal, cor cinza. Alterando no código (.Bold = False) para (.Bold = True) os binários (0-1) ficam em negrito cinza, então queria fazer e não deu muito certo, é manter o binário 1 (.Bold = False) original e o binário 0 em (.Bold = True) mas com a cor black, resumindo, 1 cinza normal e 0 black negrito.

Sub Diagonal()

Dim Intervalo As Range

Dim Coluna1 As Range

Dim Celula As Range

Dim i As Integer

Dim QtdeAzul As Integer

Dim QtEnc As Integer

Application.ScreenUpdating = False

QtdeAzul = [A1].Value

Set Intervalo = [A3:G10]

With Intervalo.Font

.ColorIndex = 15

.Bold = False

End With

For Each Celula In Coluna1

Celula.Select

QtEnc = 0

While ActiveCell.Value = 1 And Not Application.Intersect(ActiveCell, Intervalo) Is Nothing

QtEnc = QtEnc + 1

ActiveCell.Offset(-1, 1).Select

Wend

If QtEnc = QtdeAzul Then

For i = 1 To QtdeAzul

ActiveCell.Offset(1, -1).Select

ActiveCell.Font.Color = vbBlue

ActiveCell.Font.Bold = True

Next

End If

Next

Application.ScreenUpdating = True

End Sub

Cumps

Link to comment
Share on other sites

boas

substitua o cod seguinte em cada modulo e declare uma variavel range para a variavel Celula2.

With Intervalo.Font
.ColorIndex = 15
.Bold = False
End With

por isto:

For Each Celula2 In Intervalo.Cells
		 If Celula2.Value = 0 Then
		 Celula2.Font.Color = vbBlack
		 Celula2.Font.Bold = True
		 Celula2.Interior.Color = xlNone
		 Else
		 Celula2.Font.ColorIndex = 15
		 Celula2.Font.Bold = False
		 Celula2.Interior.Color = xlNone
		 End If
		 Next

não sei se reparou mas o programa não corre o range todo (grelha) e interrompe a diagonal quando encontra um zero.

Edited by acao
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.