G
Guest
Being a novice with VBA I thought I would try my hand at writing a simple
program for my inventory. It seems to work okay (eventually) with the
exception of how it sorts. I want to sort by part numbers, which are numbers
of varying lengths, or a combination numbers and letters also different
lengths. I tried creating a custom sort by doing it as a macro then copying
and pasting into my program but it’s not doing exactly what I was hoping. My
problem is that when I enter a part number for example 3661 the sort routine
in my program place it before number say 189912 obviously because of its
value. What I want to achieve is numbers sorted from the first digit then the
next and so on. I.E. 1889912, 1889913, 1901, 19014, 2101, 21981 AN174-10,
AN174-11 etc, From a previous question I submitted along these line I was
told to enter the numbers as text then they will be sorted alphabetically. On
a test I did this seemed to do the trick but now I need to now how I can
convert approximately 1000 numbers that I have already entered into text
–quite easy doing it the other way. Second, for the part numbers I will need
to add in the future I tried modifying my program but I’m not sure what I’m
doing wrong. I changed the ‘enter’ portion of my program from
Cells(intRowCounter, 1) = txtPartNumber.Value to = txtPartNumber.Text but it
would appear that they are still entered as a number and not text, making the
sort routine sort by value and not alphabetically. Chances are I’m missing
something here quite simply but I would appreciate any suggestions.
program for my inventory. It seems to work okay (eventually) with the
exception of how it sorts. I want to sort by part numbers, which are numbers
of varying lengths, or a combination numbers and letters also different
lengths. I tried creating a custom sort by doing it as a macro then copying
and pasting into my program but it’s not doing exactly what I was hoping. My
problem is that when I enter a part number for example 3661 the sort routine
in my program place it before number say 189912 obviously because of its
value. What I want to achieve is numbers sorted from the first digit then the
next and so on. I.E. 1889912, 1889913, 1901, 19014, 2101, 21981 AN174-10,
AN174-11 etc, From a previous question I submitted along these line I was
told to enter the numbers as text then they will be sorted alphabetically. On
a test I did this seemed to do the trick but now I need to now how I can
convert approximately 1000 numbers that I have already entered into text
–quite easy doing it the other way. Second, for the part numbers I will need
to add in the future I tried modifying my program but I’m not sure what I’m
doing wrong. I changed the ‘enter’ portion of my program from
Cells(intRowCounter, 1) = txtPartNumber.Value to = txtPartNumber.Text but it
would appear that they are still entered as a number and not text, making the
sort routine sort by value and not alphabetically. Chances are I’m missing
something here quite simply but I would appreciate any suggestions.