|
Anthony's VBA Forum Where the knowledge is shared |
|
|
View previous topic :: View next topic |
Author |
Message |
michilson
Joined: 20 Dec 2007 Posts: 1
|
Posted: Thu Dec 20, 2007 2:49 pm Post subject: VBA Codes For EXCEL HELP GUYS |
|
|
I need help with some coding for Excel. Heres what im looking to do and what i have so far.
I have created a userform to mark a reservation of a theater seat based on the text in a cell in a spread sheet (seat1.xls).
I want to also beable to apply and name and phone number from a seperate Execl (customers.xls) file to a corrisponding cell for the reservation.
I have a Userform in the customers file that allows me to enter information into the cells as a database would.
I have 3 text boxs on the seat1 form that i want to link to the customers data. (Phone Number, Last Name, First Name)
I also would like that in the Customers form if they enter a Phone number that already exists in the spreadsheet that it brings up all other corisponding data.
This is all writen in VBA
heres the coding to the customer form to place data in that spread sheet.
Private Sub Cmdsave_Click()
Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customers")
'find first empty row in database
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a phone number
If Trim(Me.txtphone.Value) = "" Then
Me.txtphone.SetFocus
MsgBox "please Enter A Phone Number"
Exit Sub
End If
'copy data to the database
ws.Cells(irow, 1).Value = Me.txtphone.Value
ws.Cells(irow, 2).Value = Me.txtfirst.Value
ws.Cells(irow, 3).Value = Me.txtlast.Value
ws.Cells(irow, 4).Value = Me.txtaddress.Value
ws.Cells(irow, 5).Value = Me.txtcity.Value
ws.Cells(irow, 6).Value = Me.txtstate.Value
ws.Cells(irow, 7).Value = Me.txtzip.Value
'clear data
Me.txtphone.Value = ""
Me.txtfirst.Value = ""
Me.txtlast.Value = ""
Me.txtaddress.Value = ""
Me.txtcity.Value = ""
Me.txtstate.Value = ""
Me.txtzip.Value = ""
Please help me make this search for the corisponding data when the phone number is added to the txtphone text box.
and the coding i'll need to add the the seating form to come to the customer file and search the phone number for the first and last name and insert them into the correct text boxs.
If anyone would like to see the forms i can try to post a few screen shots
________
[URL=http://www.toyota-wiki.com/wiki/Subaru_EF_engine]Subaru EF engine history[/URL] |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|