Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/05/2011, 21:35
anavlis
 
Fecha de Ingreso: mayo-2011
Mensajes: 6
Antigüedad: 13 años
Puntos: 0
macro para transponer

Hola estoy haciendo una macro en excel y tengo una duda de como realizar lo siguiente.
Lo que pasa es que tengo una base que esta en excel y tiene los siguientes campos: nombre, fecha, pregunta 1, pregunta2, pregunta 3 y pregunta4.
En los campos de nombre pregunta 1, pregunta2, pregunta 3 y pregunta4 tengo numeros tales como 2.3 , 4.5, etc lo que quiero es realizar una macro en otra hoja del excel en donde todo esto se reduzca a solo 4 campos : nombre, pregunta, nota y fecha. En el campo donde dice pregunta estarian de manera vertical todos las preguntas y en el campo donde dice nota iria el puntaje q la persona le puso. Para explicarme mejor les pongo el formato de mi base:

De esto:

Nombre Fecha Pregunta1 Pregunta2 Pregunta3 Pregunta4 Ramirez Enero 2.3 4.5 3.6 7.4
Ibarra Enero 3,7 6.5 7.8 8

a esto:

Nombre Pregunta nota fecha
Ramirez pregunta1 2.3 enero
Ramirez pregunta2 4.5 enero
Ramirez pregunta3 3.6 enero
Ramirez pregunta4 7.4 enero
Ibarra pregunta1 3.7 enero
Ibarra pregunta2 6.5 enero
Ibarra pregunta3 7.8 enero
Ibarra pregunta4 8 enero


Para esto hice una macros que en si me corre pero nunca termina de compilar, nose si lo hice bien o es que obvie algun detalle:

Dim i As Byte, j As Byte

For j = 2 To 83
For i = 2 To 100
Sheets("Hoja3").Select
Range(Cells(i, 2), Cells(i, 2)).Select
Selection.Copy
Sheets("Hoja4").Select
ActiveSheet.Paste
Range(Cells(i, 1), Cells(i, 1)).Select
ActiveWindow.ScrollRow = 45
ActiveWindow.ScrollRow = 1
Range("B2:B78").Select
Application.CutCopyMode = False
Selection.Copy
n = i + 77
Range(Cells(n, 2), Cells(n, 2)).Select
ActiveSheet.Paste
Range(Cells(n, 1), Cells(n, 1)).Select
Application.CutCopyMode = False

m = n + 77
Selection.AutoFill Destination:=Range(Cells(n, 1), Cells(m, 1))
Range(Cells(n, 1), Cells(m, 1)).Select
s = j + 5
b = i + 76
u = m - 1
Range(Cells(b, 3), Cells(b, 7)).Select
Selection.AutoFill Destination:=Range(Cells(b, 3), Cells(u, s))
Range(Cells(3, n), Cells(7, m)).Select


Range(Cells(n, 3), Cells(m, 7)).Select

l = i - 1
Z = j + 76
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],Hoja3!R1C1:R3C83,R[1]C[8],0)"
Range(Cells(n, 3), Cells(n, 3)).Select
ActiveWindow.ScrollRow = 45
ActiveWindow.ScrollRow = 1

h = i + 74
g = j + 6
u = m - 1
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],Hoja3!R1C1:R3C83,R[-76]C[8],0)"
Range(Cells(n, 3), Cells(u, 3)).Select
Selection.AutoFill Destination:=Range(Cells(n, 3), Cells(u, 3))
Range(Cells(n, 3), Cells(u, 3)).Select
Range(Cells(n, 3), Cells(n, 3)).Select
ActiveWindow.SmallScroll Down:=4
ActiveWindow.ScrollRow = 45
ActiveWindow.ScrollRow = 90
ActiveWindow.ScrollRow = 134
Range(Cells(m, 1), Cells(m, 1)).Select
Next i
Next j

Si alguien podria darme una mano con esto se los agradeceria, al parecer estoy cerca de lograrlo pero ahi me estanque y ya no se por donde mas ir.

Gracias!!!!!!!!!!!