uerform1 with textbox1 in it is for scanning ISBN #s.
there are 2 types of ISBNs, a 10 digit and a 13 digit. the 10 digit sometimes contains letters and sometimes has a 0 as the first digit in the number. my cells and my macro are designed to enter values as numeric. so if applicable, the 0 gets cut off and/or the letters try to enter into the cell and excel gives me an error and shoots me to code. this happins because the numbers in my database are entered correctly as 13 digit ISBNs.
I need either:
(1)
A code that allows the 0 to stay in the number when entered into the cell and still be formatted as a number. A code that allows letters to be entered into the cell and still be formatted as a number. OR a way to list my database to include both the 10 digit and 13 digit ISBNs and still be able to access them using a worksheet formula that includes VLOOKUP, LOOKUP, or something like that.
OR
(2)
code that makes sure the number scanned into the textbox is 13 digits AND the first 3 digits are"978"(for some reason all 13 digit ISBNs start with 978, kinda seems like it defeats the purpose but whatever)
Im not sure how much it will help but the code i have so far is below.
there are 2 types of ISBNs, a 10 digit and a 13 digit. the 10 digit sometimes contains letters and sometimes has a 0 as the first digit in the number. my cells and my macro are designed to enter values as numeric. so if applicable, the 0 gets cut off and/or the letters try to enter into the cell and excel gives me an error and shoots me to code. this happins because the numbers in my database are entered correctly as 13 digit ISBNs.
I need either:
(1)
A code that allows the 0 to stay in the number when entered into the cell and still be formatted as a number. A code that allows letters to be entered into the cell and still be formatted as a number. OR a way to list my database to include both the 10 digit and 13 digit ISBNs and still be able to access them using a worksheet formula that includes VLOOKUP, LOOKUP, or something like that.
OR
(2)
code that makes sure the number scanned into the textbox is 13 digits AND the first 3 digits are"978"(for some reason all 13 digit ISBNs start with 978, kinda seems like it defeats the purpose but whatever)
Im not sure how much it will help but the code i have so far is below.
Code:
Private Sub ib_total_Click()
Dim i As Integer
Dim rng As Range
Dim ls As Range
Dim cr As Range
'locate the cumulative price on the scan sheet
Worksheets("Scan Search").Activate
Range("G1048576").End(xlUp).Activate
Set ls = activecell
'make sure 13 digit ISBN has been entered and was looked up and priced
If IsError(ls) Then
MsgBox "Scan Error." & vbCrLf & _
"Please check the scan and try again." & vbCrLf & _
"If the problem continues, please contact CASHFORBOOKS.", vbOKOnly, "Scan Error"
'if error then find it
Worksheets("Scan Search").Range("E1048576").End(xlUp).Activate
If Not isnumeric(activecell) Then
Do Until isnumeric(activecell)
activecell.Offset(-12, 0).Activate
Loop
End If
activecell.Offset(2, -3).Activate
Set cr = activecell
'clear scans from scan table
cr = ""
cr.Offset(1, 0) = ""
cr.Offset(2, 0) = ""
cr.Offset(3, 0) = ""
cr.Offset(4, 0) = ""
cr.Offset(5, 0) = ""
cr.Offset(6, 0) = ""
cr.Offset(7, 0) = ""
cr.Offset(8, 0) = ""
cr.Offset(9, 0) = ""
Unload Me
Unload ib_more_books
Exit Sub
End If
Set rng = Worksheets("Scan Search").Range("B15")
'find the first blank scan table
If Not IsEmpty(rng) Then
Do Until rng = ""
Set rng = rng.Offset(12, 0)
Loop
End If
'check that a number is scaned
'and enter first ISBN into form
If Not isnumeric(TextBox3) Then
MsgBox "Please scan the order.", vbOKOnly, "No Scan"
Exit Sub
Else
rng = TextBox3.Value
End If
'enter the rest of the scans into the form
If Not isnumeric(TextBox4) Then
rng.Offset(1, 0) = ""
Else
rng.Offset(1, 0) = TextBox4.Value
End If
If Not isnumeric(TextBox5) Then
rng.Offset(2, 0) = ""
Else
rng.Offset(2, 0) = TextBox5.Value
End If
If Not isnumeric(TextBox6) Then
rng.Offset(3, 0) = ""
Else
rng.Offset(3, 0) = TextBox6.Value
End If
If Not isnumeric(TextBox7) Then
rng.Offset(4, 0) = ""
Else
rng.Offset(4, 0) = TextBox7.Value
End If
If Not isnumeric(TextBox8) Then
rng.Offset(5, 0) = ""
Else
rng.Offset(5, 0) = TextBox8.Value
End If
If Not isnumeric(TextBox9) Then
rng.Offset(6, 0) = ""
Else
rng.Offset(6, 0) = TextBox9.Value
End If
If Not isnumeric(TextBox10) Then
rng.Offset(7, 0) = ""
Else
rng.Offset(7, 0) = TextBox10.Value
End If
If Not isnumeric(TextBox11) Then
rng.Offset(8, 0) = ""
Else
rng.Offset(8, 0) = TextBox11.Value
End If
If Not isnumeric(TextBox12) Then
rng.Offset(9, 0) = ""
Else
rng.Offset(9, 0) = TextBox12.Value
End If
activecell.Offset(10, 4) = 1
'set the focus to the next scan table
Application.Goto rng.Offset(12, 0)
ib_total_form.Show
End Sub