Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number? What have I got wrong here is the code below. Private Sub UserForm_Activate() TextBox1.Value = InputBox("PLEASE SCAN THE ITEM") End Sub Private Sub TextBox1_Change() Dim CHECK1 Sheet5.Activate On Error Resume Next CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0) If Not IsError(CHECK1) Then Label1.Caption = Application.Index(Range("B:B"), CHECK1) End If On Error GoTo 0 End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
What is a typical barcode number that is causing problems. What error
message are you getting? -- Regards, Tom Ogilvy "Greg B" wrote: I am having trouble with a piece of code, the code works with smaller numbers but when I scan a barcode it does not recognise the number? What have I got wrong here is the code below. Private Sub UserForm_Activate() TextBox1.Value = InputBox("PLEASE SCAN THE ITEM") End Sub Private Sub TextBox1_Change() Dim CHECK1 Sheet5.Activate On Error Resume Next CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0) If Not IsError(CHECK1) Then Label1.Caption = Application.Index(Range("B:B"), CHECK1) End If On Error GoTo 0 End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
this is the example barcode scanned 9310072020280 the code works with
smaller numbers it does not seem to recognise the 9310072020280 There is no error code as such just the caption does not change with the larger number. "Tom Ogilvy" wrote in message ... What is a typical barcode number that is causing problems. What error message are you getting? -- Regards, Tom Ogilvy "Greg B" wrote: I am having trouble with a piece of code, the code works with smaller numbers but when I scan a barcode it does not recognise the number? What have I got wrong here is the code below. Private Sub UserForm_Activate() TextBox1.Value = InputBox("PLEASE SCAN THE ITEM") End Sub Private Sub TextBox1_Change() Dim CHECK1 Sheet5.Activate On Error Resume Next CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0) If Not IsError(CHECK1) Then Label1.Caption = Application.Index(Range("B:B"), CHECK1) End If On Error GoTo 0 End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
Gregg,
From Help on the LONG data type: Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration character for Long is the ampersand (&). 9,310,072,020,280 is outside this range. Try converting the number to a double (cdbl) since numbers in the excel sheet are stored as double anyway. Demo'd from the immediate window: ? cdbl("9310072020280") 9310072020280 -- Regards, Tom Ogilvy "Greg B" wrote: this is the example barcode scanned 9310072020280 the code works with smaller numbers it does not seem to recognise the 9310072020280 There is no error code as such just the caption does not change with the larger number. "Tom Ogilvy" wrote in message ... What is a typical barcode number that is causing problems. What error message are you getting? -- Regards, Tom Ogilvy "Greg B" wrote: I am having trouble with a piece of code, the code works with smaller numbers but when I scan a barcode it does not recognise the number? What have I got wrong here is the code below. Private Sub UserForm_Activate() TextBox1.Value = InputBox("PLEASE SCAN THE ITEM") End Sub Private Sub TextBox1_Change() Dim CHECK1 Sheet5.Activate On Error Resume Next CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0) If Not IsError(CHECK1) Then Label1.Caption = Application.Index(Range("B:B"), CHECK1) End If On Error GoTo 0 End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code please
Just to follow up on Tom's reply to you...
The reason you don't see anything is because the number is outside the range of a Long, your assignment is generating an error, but your On Error Resume Next statement is hiding that from you. Comment out that statement and you should be able to see the error. Rick "Tom Ogilvy" wrote in message ... Gregg, From Help on the LONG data type: Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration character for Long is the ampersand (&). 9,310,072,020,280 is outside this range. Try converting the number to a double (cdbl) since numbers in the excel sheet are stored as double anyway. Demo'd from the immediate window: ? cdbl("9310072020280") 9310072020280 -- Regards, Tom Ogilvy "Greg B" wrote: this is the example barcode scanned 9310072020280 the code works with smaller numbers it does not seem to recognise the 9310072020280 There is no error code as such just the caption does not change with the larger number. "Tom Ogilvy" wrote in message ... What is a typical barcode number that is causing problems. What error message are you getting? -- Regards, Tom Ogilvy "Greg B" wrote: I am having trouble with a piece of code, the code works with smaller numbers but when I scan a barcode it does not recognise the number? What have I got wrong here is the code below. Private Sub UserForm_Activate() TextBox1.Value = InputBox("PLEASE SCAN THE ITEM") End Sub Private Sub TextBox1_Change() Dim CHECK1 Sheet5.Activate On Error Resume Next CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0) If Not IsError(CHECK1) Then Label1.Caption = Application.Index(Range("B:B"), CHECK1) End If On Error GoTo 0 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |