Está en la página 1de 2

paso 1: activar desarrollador en excel

para activar se debe ir a archivo + opciones + personalizar cinta de opciones


(dentro buscar desarrollador y activarlo)

paso 2: ingresar a desarrollador + visual y copiar lo siguiente:

NOTA:SE TIENE QUE MODIFICAR LAS CASILLAS (8 + i, 3), (8 + i, 2) Y (8 + i, 1) en


donde
donde: 8 es la columna donde se inicia el conteo
i es la variante (no se toca)
3 es la fila que se va afectar
para esta ejemplo se va a afectar la casilla 8C que equivale a (8 + i, 3)

Sub generar_item()
i = 0
index1 = 0
Do While Cells(8 + i, 3) <> ""

If Cells(8 + i, 1) = "t" Then


Range(Cells(8 + i, 2), Cells(8 + i, 3)).Font.Bold = True
Else
Range(Cells(8 + i, 2), Cells(8 + i, 3)).Font.Bold = False
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(0, 0, 0)
End If

If Cells(8 + i, 3).IndentLevel = 0 Then


index1 = index1 + 1
index2 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(255, 0, 0)
ElseIf Cells(8 + i, 3).IndentLevel = 1 Then
index2 = index2 + 1
index3 = 0
index4 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(0, 0, 255)
ElseIf Cells(8 + i, 3).IndentLevel = 2 Then
index3 = index3 + 1
index4 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00") &
"." & Format(index3, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(30, 112, 26)
ElseIf Cells(8 + i, 3).IndentLevel = 3 Then
index4 = index4 + 1
index5 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00") &
"." & Format(index3, "00") & "." & Format(index4, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(226, 142, 30)
ElseIf Cells(8 + i, 3).IndentLevel = 4 Then
index5 = index5 + 1
index6 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00") &
"." & Format(index3, "00") & "." & Format(index4, "00") & "." & Format(index5,
"00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(238, 18, 196)
ElseIf Cells(8 + i, 3).IndentLevel = 5 Then
index6 = index6 + 1
index7 = 0
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00") &
"." & Format(index3, "00") & "." & Format(index4, "00") & "." & Format(index5,
"00") & "." & Format(index6, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(35, 159, 221)
ElseIf Cells(8 + i, 3).IndentLevel = 6 Then
index7 = index7 + 1
Cells(8 + i, 2) = "'" & Format(index1, "00") & "." & Format(index2, "00") &
"." & Format(index3, "00") & "." & Format(index4, "00") & "." & Format(index5,
"00") & "." & Format(index6, "00") & "." & Format(index7, "00")
If Cells(8 + i, 1) = "t" Then Range(Cells(8 + i, 2), Cells(8 + i,
3)).Font.Color = RGB(199, 199, 27)
End If

i = i + 1
Loop
End Sub

También podría gustarte