Macros

Solo disponible en BuenasTareas
  • Páginas : 43 (10626 palabras )
  • Descarga(s) : 12
  • Publicado : 6 de marzo de 2009
Leer documento completo
Vista previa del texto
Private Sub CommandButton1_Click()

' NOS POSICIONA EN LA HOJA 2

Sheets("CODI").Select

' INGRESA LA PALABAR FIN AL FINAL DE LA COLUMNA D EN LA CODI

a = 2

While Hoja2.Cells(a - 1, 4) "FIN"

If (Hoja2.Cells(a, 4) = 0) Then

Sheets("CODI").Range("D" & Trim(Str(a))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""FIN"")"

End Ifa = a + 1

Wend


' BORRA LA INFORMACION DE LA HOJA3

Sheets("VAR").Select
Sheets("VAR").Range("A2:G10").Select
Sheets("VAR").Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
'Sheets("VAR").Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

Sheets("VAR").Select

' INGRESAR LOS VALORES DE LA CELDA 3

a = 1While Hoja2.Cells(a, 4) "FIN"

If (Hoja2.Cells(a, 4) "FIN") Then

If (Hoja2.Cells(a + 1, 4) Hoja2.Cells(a, 4)) Then

If (Hoja2.Cells(a, 5) = "A" Or Hoja2.Cells(a, 5) = "B") Then

Sheets("VAR").Range("A" & Trim(Str(a))).Select

ActiveCell.FormulaR1C1 = "=CONCATENATE(CODI!RC[3])"Sheets("VAR").Range("G" & Trim(Str(a))).Select

ActiveCell.FormulaR1C1 = "=CONCATENATE(UPPER(CODI!RC[-5]))"

Sheets("VAR").Range("B" & Trim(Str(a))).Select

ActiveCell.FormulaR1C1 = "=CONCATENATE(CODI!RC[3])"

End If

End If

If (Hoja2.Cells(a, 4) = "FIN") Then Exit Sub

End Ifa = a + 1

Wend

' ORDENAR LOS VALORES DE LA HOJA3

Sheets("VAR").Columns("A:G").Select

Selection.Sort Key1:=Sheets("VAR").Range("A7"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'DataOption1:=xlSortNormal

' CREA LAS VARIABLES DE LAS PREGUNTAS ABIERTAS

b = 1

While Hoja3.Cells(b, 1) 0

If(Hoja3.Cells(b, 2) = "A") Then

Sheets("VAR").Rows(b + 1).Select
Selection.Insert Shift:=xlDown
Sheets("VAR").Rows(b + 2).Select
Selection.Insert Shift:=xlDown
Sheets("VAR").Rows(b + 3).Select
Selection.Insert Shift:=xlDown
Sheets("VAR").Rows(b + 4).Select
Selection.Insert Shift:=xlDown
Sheets("VAR").Rows(b + 5).Select
Selection.Insert Shift:=xlDownSheets("VAR").Rows(b + 6).Select
Selection.Insert Shift:=xlDown
Sheets("VAR").Rows(b + 7).Select
Selection.Insert Shift:=xlDown

Sheets("VAR").Range("C" & Trim(Str(b))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""COMPUTE "",RC[-2],""_1 = 0 ."")"
Sheets("VAR").Range("D" & Trim(Str(b))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""FORMAT"",RC[-3],""_1 ( F4.0 ) ."")"
Sheets("VAR").Range("E" & Trim(Str(b))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-4],""_1"")"
Sheets("VAR").Range("F" & Trim(Str(b))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""N"")"

Sheets("VAR").Range("C" & Trim(Str(b + 1))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""COMPUTE "",R[-1]C[-2],""_2 = 0 ."")"Sheets("VAR").Range("D" & Trim(Str(b + 1))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""FORMAT "",R[-1]C[-3],""_2 ( F4.0 ) ."")"
Sheets("VAR").Range("E" & Trim(Str(b + 1))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(R[-1]C[-4],""_2"")"
Sheets("VAR").Range("F" & Trim(Str(b + 1))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""N"")"

Sheets("VAR").Range("C" &Trim(Str(b + 2))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""COMPUTE "",R[-2]C[-2],""_3 = 0 ."")"
Sheets("VAR").Range("D" & Trim(Str(b + 2))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(""FORMAT "",R[-2]C[-3],""_3 ( F4.0 ) ."")"
Sheets("VAR").Range("E" & Trim(Str(b + 2))).Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(R[-2]C[-4],""_3"")"
Sheets("VAR").Range("F" &...
tracking img