Andrew1234
New Member
- Joined
- Feb 1, 2023
- Messages
- 29
- Office Version
- 2013
- Platform
- Windows
Hi i have a piece of code that is not working correctly for numbers. it will work perfectly when the cell value has at least one letter in it, but if the cell value is only numbers it will not work.
I have a very limited understanding of VBA so any help at all is very much appreciated!
here is the code that am currently using.
Engine B9 show the last selected barcode. Engine B5 is meant to show the row that the selected barcode is in.
If there is no issue with the code i think think that my issue could be something to do with how my cell is formatted as when it is stored as a number the cell value is something like this ... 5.01102E+12
whereas when it is stored as text it will just show the barcode as it is ...5011020103539
Also... When i select a barcode that has only numbers i can see in my engine sheet that the value of B9 will be stored as a text even though it is a number.
Everytime i change the format of engine B9 to general but it always autochanges back to text when i select a new product from the list box. Could this be my issue?
Cell B9 is generated from a listbox within a userform. I have a search userform that i search for products on and then click the product i require then i can click an edit button. (the edit button is the one that has the .Match code in it)
There are many areas that could cause this issue so i am very grateful to anyone who takes the time to help me.
Many thanks in advance!
Andrew
I have a very limited understanding of VBA so any help at all is very much appreciated!
here is the code that am currently using.
VBA Code:
Dim TargetRow As Integer
TargetRow = Application.WorksheetFunction.Match(Sheets("Engine").Range("B9").Value, Sheets("Product Data").Range("dyn_Product_Barcode"), 0)
Sheets("Engine").Range("B5") = TargetRow
Engine B9 show the last selected barcode. Engine B5 is meant to show the row that the selected barcode is in.
If there is no issue with the code i think think that my issue could be something to do with how my cell is formatted as when it is stored as a number the cell value is something like this ... 5.01102E+12
whereas when it is stored as text it will just show the barcode as it is ...5011020103539
Also... When i select a barcode that has only numbers i can see in my engine sheet that the value of B9 will be stored as a text even though it is a number.
Everytime i change the format of engine B9 to general but it always autochanges back to text when i select a new product from the list box. Could this be my issue?
Cell B9 is generated from a listbox within a userform. I have a search userform that i search for products on and then click the product i require then i can click an edit button. (the edit button is the one that has the .Match code in it)
There are many areas that could cause this issue so i am very grateful to anyone who takes the time to help me.
Many thanks in advance!
Andrew