Ver Mensaje Individual
  #13 (permalink)  
Antiguo 14/07/2010, 03:05
JLMESEGUER
 
Fecha de Ingreso: julio-2010
Mensajes: 1
Antigüedad: 13 años, 9 meses
Puntos: 0
boton en excel para meter datos en otra hoja con un input box

Buenos días.

Necesito ayuda sobre una asuntillo,

Tengo una hoja 3 que está referenciada a un boton y cuando hago click el codigo falla
si me voy a la hoja 4 el codigo funciona....pero si ejecuto el boton desde la macro en la hoja de codigo no desde el boton de la hoja.
Adjunto codigo:
Private Sub CommandButton2_Click()
Dim Cliente As String
Dim Obra As String
Dim Lugar As String
Dim Fecha As String
Dim Proyecto As String
Dim Informe As String
Dim strMsg As String
Cliente = InputBox("Inserte Nombre Cliente:", "Nuevo informe")
Obra = InputBox("Inserte Obra:", "Nuevo informe")
Lugar = InputBox("Inserte Lugar del ensayo:", "Nuevo informe")
Fecha = InputBox("Inserte fecha de realizacion del ensayo:", "Nuevo informe")
Proyecto = InputBox("Inserte Proyecto:", "Nuevo informe")
strMsg = "ha creado informe " & Cliente & ", " & Fecha & " ha sido creado"
MsgBox strMsg
Dim hoja As Worksheet
Dim celda As Characters
For Each hoja In Sheets
Hoja3.Range("I10") = Cliente
Hoja3.Range("CC10") = Informe
Hoja3.Range("G15") = Obra
Hoja3.Range("AW15") = Lugar
Hoja3.Range("BZ15") = Fecha
Hoja3.Range("K20") = Proyecto
Next hoja
Application.ScreenUpdating = False


Hoja4.Range("C4").Select ' aqui es donde me falla

Do While Not IsEmpty(ActiveCell)
'Pues eso, hasta que no encuentre una fila
'vacía que baje una fila para abajo
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = Cliente

'================================================= =====================
Hoja4.Range("G4").Select
Do While Not IsEmpty(ActiveCell)
'Pues eso, hasta que no encuentre una fila
'vacía que baje una fila para abajo
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = Obra
'================================================= =====================
Hoja4.Range("I4").Select


Do While Not IsEmpty(ActiveCell)
'Pues eso, hasta que no encuentre una fila
'vacía que baje una fila para abajo
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = Lugar
'================================================= =====================
Hoja4.Range("K4").Select
Do While Not IsEmpty(ActiveCell)
'Pues eso, hasta que no encuentre una fila
'vacía que baje una fila para abajo
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = Fecha
'================================================= =====================
Hoja4.Range("M4").Select

Do While Not IsEmpty(ActiveCell)
'Pues eso, hasta que no encuentre una fila
'vacía que baje una fila para abajo
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell = Proyecto
'================================================= =====================

Application.ScreenUpdating = True
End Sub