Jump to content

Modificar codigo en macro


Recommended Posts

Hola amigos, 

 

Tengo esta macro que habia venido usando para registrar entradas de dinero, ahora la modifique para que sea entrada de progresos de pacientes. En el campo pago solo se permite usar numeros, quiero cambiarlo a texto pero no estoy seguro donde debo modificar el codigo. EL archivo esta adjunto aqui y el codigo es el siguiente

 

Private Sub CommandButton1_Click()
Dim Uc As Integer
Dim I As Integer
Dim Uf As String
Dim Pago As Double

With Hoja3

Uf = .Range("A" & Rows.Count).End(xlUp).Row
Pago = TxtPago

    For I = 1 To Uf
        
            Uc = .Cells(I, Columns.Count).End(xlToLeft).Column
            
            
                If ComboBox1.Text = .Cells(I, 2).Text Then
            
            
                    .Cells(I, Uc).Offset(0, 1) = CDbl(TxtPago)
                    .Cells(I, Uc).Offset(0, 2) = TxtConcepto
                    .Cells(I, Uc).Offset(0, 3) = CDate(Date)
                    
                    Exit For
                End If
                  
    Next
                
        MsgBox "REGISTRADO SATISFACTORIAMENTE", vbInformation, "PROCESADO"
    
End With

End Sub

 

Link to comment
Share on other sites

Cambia tu código por este modificado

Private Sub CommandButton1_Click()
Dim Uc As Integer
Dim I As Integer
Dim Uf As String
Dim Pago As String

With Hoja3

Uf = .Range("A" & Rows.Count).End(xlUp).Row
Pago = TxtPago

    For I = 1 To Uf
        
            Uc = .Cells(I, Columns.Count).End(xlToLeft).Column
            
            
                If ComboBox1.Text = .Cells(I, 2).Text Then
            
            
                    .Cells(I, Uc).Offset(0, 1) = TxtPago
                    .Cells(I, Uc).Offset(0, 2) = TxtConcepto
                    .Cells(I, Uc).Offset(0, 3) = CDate(Date)
                    
                    Exit For
                End If
                  
    Next
                
        MsgBox "REGISTRADO SATISFACTORIAMENTE", vbInformation, "PROCESADO"
    
End With

End Sub

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Privacy Policy