Folks.
A novice to VBA, I have created a user form that data enters individually numbered Quality cards (QC) into a spreadsheet.
I am trying to find out how I write the code to check to see if the QC has previously been entered before it executes the populate code?
The number is additionally annoying as when my code does populate the spreadsheet it populates the number as text. I physically need to go into my spreadsheet and convert all enrtered cards to number format. Does anyone have a solution to that? Voucher.Value refers to the QC number textbox.
Current code
Private Sub actionstaken_Change()
End Sub
Private Sub Allocated_Change()
End Sub
Private Sub btnAddMETL_Click()
Dim iRow As Long
Dim ws As Worksheet
Voucher.Value = CDec(Voucher.Value)
'''''''''''''''''''''''''''''''''''''''''''''''''
' Get the values from the form and stick the values
' into a few global variables
'''''''''''''''''''''''''''''''''''''''''''''''''
gsCallSign = Callsign.Value
gsVoucher = Voucher.Value
gsObserver = OT.Value
gdDateTime = DateTime.Value
gsObservations = Observations.Value
gsRecommendation1 = Recommendation1.Value
gsScenarioNo = ScenarioNo.Value
gsAllocated = Allocated.Value
gsCourse = Course.Value
gsActionstaken = Actionstaken.Value
gsDateclosed = Dateclosed.Value
gsClosedby = Closedby.Value
gsAdvised = Advised.Value
''''''''''''''''''''''''''''''''''''''''''''''''''
' Pick the data storage Worksheet
''''''''''''''''''''''''''''''''''''''''''''''''''
Set ws = Worksheets("Quality Cards")
Sheets("Quality Cards").Select
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
''''''''''''''''''''''''''''''''''''''''''''''''''
' Transfer the data from the form to the data sheet
''''''''''''''''''''''''''''''''''''''''''''''''''
Cells(iRow, 1).Value = gsVoucher
Cells(iRow, 2).Value = gdDateTime
Cells(iRow, 3).Value = gsObserver
Cells(iRow, 4).Value = gsScenarioNo
Cells(iRow, 5).Value = gsCallSign
Cells(iRow, 6).Value = gsCourse
Cells(iRow, 7).Value = gsObservations
Cells(iRow, 8).Value = gsRecommendation1
Cells(iRow, 9).Value = gsAllocated
Cells(iRow, 10).Value = gsActionstaken
Cells(iRow, 11).Value = gsDateclosed
Cells(iRow, 12).Value = gsClosedby
Cells(iRow, 13).Value = gsAdvised
Sheets("Entry Form").Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Once the data has been written to the data sheet
' reset the form by removing the fields most likely to change
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Callsign.Value = ""
Voucher.Value = ""
OT.Value = gsObserver
DateTime.Value = gdDateTime
Observations.Value = ""
Recommendation1.Value = ""
ScenarioNo.Value = gsScenarioNo
Allocated.Value = ""
Course.Value = ""
Actionstaken.Value = ""
Dateclosed.Value = ""
Closedby.Value = ""
Advised.Value = ""
Voucher.SetFocus
' Now we go back to the form for entry of the next Observation.
End Sub
Bookmarks