Write Data to Excel Database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an input form that I am trying to update an excel database with. What
I need the macro to do is using the account number find the entry in the
database and write the value that are on the input form.

Would the find and offset be the best way to do this or is their another
alternative.
 
Hi,

If you are using a userform then this may help.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
'' This assumns you have a userform1 with txtbox named txtaccount
With UserForm1
Cells.Find(What:=txtaccount, LookIn:=xlValues, LookAt:=xlPart).Activate
If Err = "91" Then
MsgBox "Could not find Account: " & .txtaccount
Exit Sub
End If
''' assumes account is in column "A" '''
Cells(ActiveCell, 2).Value = .txtmytxt1 ''' assumes value goes in column
2
''or Cells(ActiveCell, 1).Offset(,1).Value = .txtmytxt1''' assumes value
goes in column 2
Cells(ActiveCell, 3).Value = .txtmytxt2 ''' assumes value goes in column
3
Cells(ActiveCell, 4).Value = .txtmytxt3 ''' assumns value goes in column
4
Cells(ActiveCell, 5).Value = .txtmytxt4 ''' assumns value goes in column
5
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top