Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Insertar Datos En Hoja Uno Abajo De Otro

Estas en el tema de Insertar Datos En Hoja Uno Abajo De Otro en el foro de Visual Basic clásico en Foros del Web. hola, quisiera me pudieran ayudar o dar ideas de como realizar una funcion, lo que pasa esque ya "termine" la macros es una encuesta e ...
  #1 (permalink)  
Antiguo 07/05/2008, 13:10
 
Fecha de Ingreso: abril-2008
Mensajes: 10
Antigüedad: 16 años, 1 mes
Puntos: 0
Pregunta Insertar Datos En Hoja Uno Abajo De Otro

hola, quisiera me pudieran ayudar o dar ideas de como realizar una funcion, lo que pasa esque ya "termine" la macros es una encuesta e inserta datos a hojas lo que pasa esqe al insertar datos inserta el primer dato en la celda A12 y este seria el primero y el segundo al insertarse dezplaza a este primer dato y el segundo dato se qeda como primero y asi sucesivamente ahora lo que me pidieron esque eso ya no suceda me pidieron que el primer dato siempre se qede en la celda A12 y al ingresar otro dato pues se vaya a la celda A13 y asi sucesivamente, mi problema es que pues batalle mucho para hacer el codigo que termine porqe soy nuevo en esto y quisiera saber si alguien me puede dar opciones o ideas de como realizar lo que me piden de antemano gracias saludos..

aqui les dejo la macros esta en office 2007 ahi viene todo gracias.


http://download.yousendit.com/8B1ECB12008431AD
  #2 (permalink)  
Antiguo 07/05/2008, 13:43
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Re: Insertar Datos En Hoja Uno Abajo De Otro

Cita:
Iniciado por chicharroni Ver Mensaje
hola, quisiera me pudieran ayudar o dar ideas de como realizar una funcion, lo que pasa esque ya "termine" la macros es una encuesta e inserta datos a hojas lo que pasa esqe al insertar datos inserta el primer dato en la celda A12 y este seria el primero y el segundo al insertarse dezplaza a este primer dato y el segundo dato se qeda como primero y asi sucesivamente ahora lo que me pidieron esque eso ya no suceda me pidieron que el primer dato siempre se qede en la celda A12 y al ingresar otro dato pues se vaya a la celda A13 y asi sucesivamente, mi problema es que pues batalle mucho para hacer el codigo que termine porqe soy nuevo en esto y quisiera saber si alguien me puede dar opciones o ideas de como realizar lo que me piden de antemano gracias saludos..

aqui les dejo la macros esta en office 2007 ahi viene todo gracias.


http://download.yousendit.com/8B1ECB12008431AD
No puedo descargar tu archivo porque no tengo Office 2007, podrías guardar en formato de Office anterior para que otros no tengan el mismo problema.

Podrías simplemente usar Range:
Código:
ThisWorkBook.WorkSheets(1).Range("A12") = "Value"
y simplemente vas cambiando el índice...
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #3 (permalink)  
Antiguo 08/05/2008, 10:35
 
Fecha de Ingreso: abril-2008
Mensajes: 10
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Insertar Datos En Hoja Uno Abajo De Otro

Cita:
Iniciado por David el Grande Ver Mensaje
No puedo descargar tu archivo porque no tengo Office 2007, podrías guardar en formato de Office anterior para que otros no tengan el mismo problema.

Podrías simplemente usar Range:
Código:
ThisWorkBook.WorkSheets(1).Range("A12") = "Value"
y simplemente vas cambiando el índice...
hola mira aqui esta el archivo para versiones anteriores de office espero puedas ayudarme y el range ya lo utilize pero creo que es algo mas complicado yo pienso que puede ser un LOOP o un FOR pero aun no se bien como utlizarlos para la macros espero me puedas dar unos tips de antemano gracias aqui dejo el link con el archivo...

http://download.yousendit.com/4F39744001F33752
  #4 (permalink)  
Antiguo 08/05/2008, 12:31
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
De acuerdo Re: Insertar Datos En Hoja Uno Abajo De Otro

Lo que modifiqué fue esto:
Código:
 
Private Function FindEmptyCell(Init As Byte) As String
Dim Count As Integer
Do
    If Worksheets("Pregunta1").Range("a" & CStr(Init + Count)) = "" Then
        FindEmptyCell = CStr(Init + Count)
        Exit Function
    End If
    Count = Count + 1
Loop
End Function
Private Sub CommandButton1_Click()
Rem If TextBox4 <> Empty Then
Dim vCell As String
vCell = FindEmptyCell(12)
Worksheets("Pregunta3").Activate
Range("c" & vCell).Select
Selection.EntireRow.Insert
If i = 1 Then
Worksheets("Pregunta3").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = i
Else
Worksheets("Pregunta3").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If j = 1 Then
Worksheets("Pregunta3").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = j
Else
Worksheets("Pregunta3").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If k = 1 Then
Worksheets("Pregunta3").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = k
Else
Worksheets("Pregunta3").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If l = 1 Then
Worksheets("Pregunta3").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = l
Else
Worksheets("Pregunta3").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
Worksheets("Pregunta3").Range("a" & vCell).Value = TextBox1
Worksheets("Pregunta3").Range("b" & vCell).Value = TextBox4
Worksheets("Pregunta2").Activate
Range("c" & vCell).Select
Selection.EntireRow.Insert
If e = 1 Then
Worksheets("Pregunta2").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = e
Else
Worksheets("Pregunta2").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If f = 1 Then
Worksheets("Pregunta2").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = f
Else
Worksheets("Pregunta2").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If g = 1 Then
Worksheets("Pregunta2").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = g
Else
Worksheets("Pregunta2").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If h = 1 Then
Worksheets("Pregunta2").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = h
Else
Worksheets("Pregunta2").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
Worksheets("Pregunta2").Range("a" & vCell).Value = TextBox1
Worksheets("Pregunta2").Range("b" & vCell).Value = TextBox4
Worksheets("Pregunta1").Activate
Range("c" & vCell).Select
Selection.EntireRow.Insert
If a = 1 Then
Worksheets("Pregunta1").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = a
Else
Worksheets("Pregunta1").Range("c" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If b = 1 Then
Worksheets("Pregunta1").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = b
Else
Worksheets("Pregunta1").Range("d" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If c = 1 Then
Worksheets("Pregunta1").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = c
Else
Worksheets("Pregunta1").Range("e" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
If d = 1 Then
Worksheets("Pregunta1").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = d
Else
Worksheets("Pregunta1").Range("f" & vCell).Select
ActiveCell.FormulaR1C1 = 0
End If
Worksheets("Pregunta1").Range("a" & vCell).Value = TextBox1
Worksheets("Pregunta1").Range("b" & vCell).Value = TextBox4
Worksheets("calificacion").Activate
Range("c" & vCell).Select
Selection.EntireRow.Insert
Worksheets("Calificacion").Range("b" & vCell).Value = TextBox4
Worksheets("Calificacion").Range("a" & vCell).Value = TextBox1
Worksheets("Calificacion").Range("c" & vCell).Value = ComboBox1.Value
Worksheets("Observaciones").Activate
Range("c" & vCell).Select
Selection.EntireRow.Insert
Worksheets("Observaciones").Range("b" & vCell).Value = TextBox4
Worksheets("Observaciones").Range("a" & vCell).Value = TextBox1
Worksheets("Observaciones").Range("c" & vCell).Value = TextBox3
Rem Empty Limpia Los Textbox
TextBox4 = Empty
TextBox3 = Empty
ComboBox1 = 10
Rem Textbox1SetFocus Envia el cursor al Textbox1 para volver a capturar los datos
TextBox1.SetFocus
Rem Else
Rem MsgBox "Debe escribir su nombre"
Rem TextBox4.SetFocus
Rem End If
End Sub
Así en vez de seleccionar la celda 12, seleccionamos la primera celda vacía que encontramos en Pregunta1...
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #5 (permalink)  
Antiguo 12/05/2008, 12:39
 
Fecha de Ingreso: abril-2008
Mensajes: 10
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: Insertar Datos En Hoja Uno Abajo De Otro

muchas gracias DAVID me a funcionado a la perfeccion te debo una!! gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:14.