Excel and VBA form

Mythri Hegde

New Member
Joined
Apr 20, 2011
Messages
11
Hi All,

I have created a form and it is working fine. Here is my form

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim iAction As Long
Dim iPriority As Long
Dim ws As Worksheet
Set ws = Worksheets("PlanningActions")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.txtAction.Value) = "" Then
Me.txtAction.SetFocus
MsgBox "Please enter an Action"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtAction.Value
ws.Cells(iRow, 2).Value = Me.txtTopic.Value
ws.Cells(iRow, 3).Value = Me.txtPerson.Value
ws.Cells(iRow, 4).Value = Me.txtLocation.Value
ws.Cells(iRow, 5).Value = Me.txtDate.Value
ws.Cells(iRow, 6).Value = Me.txtContact.Value
ws.Cells(iRow, 7).Value = Me.cboPriority.Value
ws.Cells(iRow, 8).Value = Me.cboPriority.List(iPriority, 1)



'clear the data
Me.txtAction.Value = ""
Me.txtTopic.Value = ""
Me.txtPerson.Value = ""
Me.txtLocation.Value = ""
Me.txtDate.Value = ""
Me.txtContact.Value = ""
Me.cboPriority.Value = ""

Me.txtAction.SetFocus

End Sub


Private Sub cmdClose_Click()
Unload Me
End Sub




Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub

Private Sub UserForm_Initialize()
Dim cPri As Range
Dim cLoc As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")

For Each cPri In ws.Range("Priority")
With Me.cboPriority
.AddItem cPri.Value
.List(.ListCount - 1, 0) = cPri.Offset(0, 1).Value
End With
Next cPri



Me.txtAction.Value = ""
Me.txtTopic.Value = ""
Me.txtPerson.Value = ""
Me.txtLocation.Value = ""
Me.txtDate.Value = ""
Me.txtContact.Value = ""
Me.cboPriority.Value = ""
Me.txtAction.SetFocus


End Sub


In my excelsheet already unique ID's of the person has been entered. when the data is entered through this form it should search that particular ID and infront of that data to be entered.

How do i do that?

Thanks in advance
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top