Una duda por que no corre un if en mi código VBA
Me gustaría saber si alguien puede saber por que no me pasa el flujo de trabajo a través de un if que hay en el código
Dim celda As Range Dim dia, fechaEnca, cliente As String Dim tec As String Dim diaslect As Integer Dim diaS As String Dim iCol, iCol2 As Integer Dim ref2, ref3 As String Dim val As Integer Dim celdaz As Range Dim diaFor, fechaFor As String Dim fechaiF, diaiF As String For diaslect = 1 To 5 If diaslect = 1 Then diaS = "lunes" val = 3 End If If diaslect = 2 Then diaS = "martes" val = 4 End If If diaslect = 3 Then diaS = "miércoles" val = 5 End If If diaslect = 4 Then diaS = "jueves" val = 3 End If If diaslect = 5 Then diaS = "viernes" val = 3 End If Rem MsgBox "for1" & " " & diaS & " " & val Range("k3", ActiveSheet.Range("k65536").End(xlUp)).Select For Each celda In Selection Rem IF1 If Cells(celda.Row, 14).Value = val And Cells(celda.Row, 16).Value = val And Cells(celda.Row, 13).Value = diaS Then dia = Cells(celda.Row, 13).Value fechaEnca = Cells(celda.Row, 11).Value cliente = Cells(celda.Row, 2).Value tec = Cells(celda.Row, 7).Value Rem MsgBox "2 for " & " " & fechaEnca & " " & dia & " " & cliente & " " & tec Sheets("Hoja5").Select Rem IF2 If IsEmpty(Range("b2").Value) = True Then MsgBox "IF 1 " & " " & fechaEnca & " " & dia & " " & cliente & " " & tec Range("b3").Value = dia Range("b2").Value = fechaEnca Range("C2").Value = "TECNICO" Range("b2").End(xlDown).Select ActiveCell.Offset(1, 0).Select ActiveCell.Value = cliente ActiveCell.Offset(0, 1).Select ActiveCell.Value = tec Range("b2").Select Selection.HorizontalAlignment = xlCenter Rem IF2 End If If Not IsEmpty(Range("b2").Value) = True Then Range("b2", ActiveSheet.Range("iv2").End(xlToLeft)).Select MsgBox "pause para ver lo seleccionado" For Each celdaz In Selection diaFor = Cells(3, celdaz.Column).Value fechaFor = Cells(2, celdaz.Column).Value MsgBox "celdas column recorridas por 3 for en if" & " " & celdaz.Column Rem MsgBox ref Rem MsgBox "diaFor" & " " & Cells(3, celdaz.Column).Value & "||||" & "fechaFor" & " " & Cells(2, celdaz.Column).Value a = Cells(2, celdaz.Column).Address(False, False) b = Cells(3, celdaz.Column).Address(False, False) MsgBox a & " " & b If fechaFor <> "TECNICO" And Not IsEmpty(Range(a).Value) = True Then fechaiF = fechaFor diaiF = diaFor ref = celdaz.Address(False, False) a = Cells(2, celdaz.Column).Address(False, False) b = Cells(3, celdaz.Column).Address(False, False) End If Next Range(ref).End(xlDown).Select ActiveCell(2, 1).Select End If Rem ESTE IF NO LO CORRE If fechaFor = fechaEnca And diaFor = dia Then MsgBox "REF DE FOR en IF 2" & " " & ref Range(ref).End(xlDown).Select ActiveCell(2, 1).Select Rem MsgBox refX ActiveCell.Value = cliente ActiveCell.Offset(0, 1).Select ActiveCell.Value = tec ElseIf Not IsEmpty(Range(a).Value) = True And Not IsEmpty(Range(b).Value) = True Then MsgBox "elseif" Range("iv2").End(xlToLeft).Offset(0, 2).Select ref2 = ActiveCell.Address(False, False) MsgBox "CELDA Q HAGARRO" & " " & ref2 ActiveCell.Value = fechaEnca Selection.HorizontalAlignment = xlCenter ActiveCell(2, 1).Value = dia Range(ref2).End(xlDown).Select ActiveCell.Offset(1, 0).Select ActiveCell.Value = cliente End If End If Sheets("Hoja4").Select Next Next
Respuesta de antonio carreon
1 respuesta más de otro experto
Respuesta de Dante Amor
1