Utilizando la información proveniente de los dos posts anteriores en los que usted me dio un excelente soporte:
Me guie para intentar configurar las siguientes macros:
Sub
VerificarTextBoxes()
Dim txtBoxes As Variant
Dim contador As Integer
Dim sextoTextBox As Double
Dim septimoTextBox As Double
Dim i As Integer
txtBoxes = Array(frmvtl.TextBox16.Value,
frmvtl.TextBox17.Value, frmvtl.TextBox18.Value, frmvtl.TextBox19.Value, _
frmvtl.TextBox20.Value,
frmvtl.TextBox21.Value, frmvtl.TextBox22.Value)
contador = 0
sextoTextBox
= 0
septimoTextBox = 0
' Contar
TextBoxes llenos
For i = LBound(txtBoxes) To
UBound(txtBoxes)
If txtBoxes(i) <> ""
Then
contador = contador + 1
If contador = 6 Then
sextoTextBox = Val(txtBoxes(i))
ElseIf contador = 7 Then
septimoTextBox =
Val(txtBoxes(i))
End If
End If
Next i
' Sumar al
TextBox26 si hay 6 o 7 TextBox llenos
If contador >= 6 Then
Dim total As Double
total = sextoTextBox + septimoTextBox
frmvtl.TextBox26.Value = total
End If
End Sub
Sub
ColorearTextBox(TxtBox As MSForms.TextBox, CboBox As MSForms.comboBox)
'Colorear Texbox 16 al 20
With TxtBox
Select Case .Value
Case "", Empty:
.BackColor = RGB(255, 255, 255)
Case Is <= CInt(CboBox):
.BackColor = RGB(255, 255, 255)
Case Is > CInt(CboBox):
.BackColor = RGB(255, 0, 0)
End Select
End With
End Sub
Sub
ColorearTextBox2(TxtBox As MSForms.TextBox, CboBox As MSForms.comboBox)
'Colorear Texbox 21 y 22
With TxtBox
Select Case .Value
Case "", Empty:
.BackColor = RGB(255, 255, 255)
Case Is <> "":
.BackColor = RGB(255, 0, 0)
End Select
End With
End Sub
Con las cuales intento darle funcionalidad al siguiente argumento: Sí y solo si hay 6 o 7 TextBox llenos (TextBox<>””) de Lunes a Domingo (TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22) entonces:
· El(los) valor(es) del 6to TextBox o 7mo TextBox lleno(s) (TextBox<>””) o ambos inclusive se deberá(n) sumar automáticamente al TextBox26.
· El color del 6to TextBox o 7mo TextBox o ambos inclusive deberá(n) ser automáticamente BackColor = RGB(255, 0, 0) si esta(n) lleno(s) (TextBox<>””) y si esta(n) vacío(s) (TextBox = ””) deberá(n) ser BackColor = RGB(255, 255, 255).
· El 6to TextBox estará ubicado alternativamente entre el(los) TextBox21 y TextBox22 mientras que el 7mo TextBox siempre estará ubicado en el TextBox22.
· El(los) TextBox (TextBox16 al TextBox22) cuyo(s) valor(es) posea(n) decimales o sea(n) decimales directamente y donde adicionalmente se cumplan con las condiciones de la Macro CalcularDiferencias así como con los tres puntos anteriores dicho(s) decimal(es) se deberá(n) sumar automáticamente en el TextBox
Ahora bien, cuando los TextBox16 al TextBox22 estan llenos la macro automáticamente suma los valores del 6to TextBox y 7mo TextBox lleno(s) (TextBox<>””) en el TextBox26 y se colorean adecuadamente los TextBox21 y TextBox22 sin embargo si entre el TextBox16 y el TextBox22 hay algún TextBox vacío y/o con valores ≥ 8 se presentan desviaciones en la suma en el TextBox26, así mismo cuando los valores contenidos en los TextBox poseen decimales o son decimales directamente dichos decimales no se suman automáticamente en el TextBox 26 como si ocurre en el TextBox23 (Ver Archivo Sumar).
Mucho te sabre agradecer a ayuda que me puedas dar
Buenos días @JSDJSD espero estes bien
Utilizando la información proveniente de los dos posts anteriores en los que usted me dio un excelente soporte:
Me guie para intentar configurar las siguientes macros:
Sub VerificarTextBoxes() Dim txtBoxes As Variant Dim contador As Integer Dim sextoTextBox As Double Dim septimoTextBox As Double Dim i As Integer txtBoxes = Array(frmvtl.TextBox16.Value, frmvtl.TextBox17.Value, frmvtl.TextBox18.Value, frmvtl.TextBox19.Value, _ frmvtl.TextBox20.Value, frmvtl.TextBox21.Value, frmvtl.TextBox22.Value) contador = 0 sextoTextBox = 0 septimoTextBox = 0 ' Contar TextBoxes llenos For i = LBound(txtBoxes) To UBound(txtBoxes) If txtBoxes(i) <> "" Then contador = contador + 1 If contador = 6 Then sextoTextBox = Val(txtBoxes(i)) ElseIf contador = 7 Then septimoTextBox = Val(txtBoxes(i)) End If End If Next i ' Sumar al TextBox26 si hay 6 o 7 TextBox llenos If contador >= 6 Then Dim total As Double total = sextoTextBox + septimoTextBox frmvtl.TextBox26.Value = total End If End Sub
Sub ColorearTextBox(TxtBox As MSForms.TextBox, CboBox As MSForms.comboBox) 'Colorear Texbox 16 al 20 With TxtBox Select Case .Value Case "", Empty: .BackColor = RGB(255, 255, 255) Case Is <= CInt(CboBox): .BackColor = RGB(255, 255, 255) Case Is > CInt(CboBox): .BackColor = RGB(255, 0, 0) End Select End With End Sub
Sub ColorearTextBox2(TxtBox As MSForms.TextBox, CboBox As MSForms.comboBox) 'Colorear Texbox 21 y 22 With TxtBox Select Case .Value Case "", Empty: .BackColor = RGB(255, 255, 255) Case Is <> "": .BackColor = RGB(255, 0, 0) End Select End With End Sub
Con las cuales intento darle funcionalidad al siguiente argumento: Sí y solo si hay 6 o 7 TextBox llenos (TextBox<>””) de Lunes a Domingo (TextBox16, TextBox17, TextBox18, TextBox19, TextBox20, TextBox21, TextBox22) entonces:
· El(los) valor(es) del 6to TextBox o 7mo TextBox lleno(s) (TextBox<>””) o ambos inclusive se deberá(n) sumar automáticamente al TextBox26.
· El color del 6to TextBox o 7mo TextBox o ambos inclusive deberá(n) ser automáticamente BackColor = RGB(255, 0, 0) si esta(n) lleno(s) (TextBox<>””) y si esta(n) vacío(s) (TextBox = ””) deberá(n) ser BackColor = RGB(255, 255, 255).
· El 6to TextBox estará ubicado alternativamente entre el(los) TextBox21 y TextBox22 mientras que el 7mo TextBox siempre estará ubicado en el TextBox22.
· El(los) TextBox (TextBox16 al TextBox22) cuyo(s) valor(es) posea(n) decimales o sea(n) decimales directamente y donde adicionalmente se cumplan con las condiciones de la Macro CalcularDiferencias así como con los tres puntos anteriores dicho(s) decimal(es) se deberá(n) sumar automáticamente en el TextBox
Ahora bien, cuando los TextBox16 al TextBox22 estan llenos la macro automáticamente suma los valores del 6to TextBox y 7mo TextBox lleno(s) (TextBox<>””) en el TextBox26 y se colorean adecuadamente los TextBox21 y TextBox22 sin embargo si entre el TextBox16 y el TextBox22 hay algún TextBox vacío y/o con valores ≥ 8 se presentan desviaciones en la suma en el TextBox26, así mismo cuando los valores contenidos en los TextBox poseen decimales o son decimales directamente dichos decimales no se suman automáticamente en el TextBox 26 como si ocurre en el TextBox23 (Ver Archivo Sumar).
Mucho te sabre agradecer a ayuda que me puedas dar
Libro.xlsm