Agregar una nueva condición IF a macro ya creada
Tengo la siguiente macro:
Sub CopiarDatosColpatria()
'Por.Dante Amor
Set h1 = Sheets("Ing Colpatria")
Set h2 = Sheets("Colpatria")
Set h3 = Sheets("CONSTANTES")
'
If UCase(h1.[G16]) = "CONSULTA" Or UCase(h1.[G16]) = "CONTROL" Then
If UCase(h1.[G16]) = "CONSULTA" Then vbruto = "45870" Else vbruto = "38430"
u = 3
Do While h2.Cells(u, "A") <> ""
u = u + 1
Loop
h2.Rows(u).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
laformula = "=IF(RC[-2]="""","""",RC[-2]-RC[-1])"
ElseIf IsNumeric(h1.[G16]) Then
Set b = h3.Columns("AV").Find(h1.[G16], lookat:=xlWhole)
If Not b Is Nothing Then
If UCase(h1.[G20]) = "ORIGINAL" Then
vbruto = b.Offset(0, 3)
ElseIf UCase(h1.[G20]) = "ALTERNO" Then
vbruto = b.Offset(0, 8)
End If
End If
u = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
laformula = "=IF(RC[-2]="""","""",(RC[-2]-RC[-1])*RC[1])"
Else
vbruto = ""
u = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
laformula = ""
End If
'
h2.Cells(u, "A") = h1.[G10]
h2.Cells(u, "B") = h1.[G12]
h2.Cells(u, "C") = h1.[G8]
h2.Cells(u, "D") = h1.[G14]
h2.Cells(u, "E") = h1.[G16]
h2.Cells(u, "G") = vbruto
h2.Cells(u, "H") = h1.[G18]
h2.Cells(u, "I") = laformula
MsgBox "Datos copiados"
End SubSi te das cuenta, hay dos condiciones, una si G20 es ORIGINAL y otra si G20 es ALTERNO ahora necesito una tercera condición si G20 es H&C
Me ayudas?
Algo asi como esto:
If UCase(h1.[G20]) = "H&C" Then vbruto = b.Offset(0, 12)
Intente hacerlo yo mismo pero me salió error.
1 Respuesta
Respuesta de Dante Amor
2