Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking array to see if value exists before adding to array
Hi,
I am going round in circles as usual and am doing (at least) one stupid thing with a lack of logic, so need some help. I have a list of possible entries that someone can manually enter, which I then want to check against already entered values of an array and then if it's not in the array to add it to the next value of the array (up to 4 values). Can someone please assist me with this or point me in the right direction? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking array to see if value exists before adding to array
I think we need some more information. Where is this list of possible
entries at... In a declared VB array? In a range of cells? In a String variable? Somewhere else? Also, what do you mean by "the already entered value of an array"... is that an array of cells or a declared VB array? -- Rick (MVP - Excel) "Wullie" wrote in message ... Hi, I am going round in circles as usual and am doing (at least) one stupid thing with a lack of logic, so need some help. I have a list of possible entries that someone can manually enter, which I then want to check against already entered values of an array and then if it's not in the array to add it to the next value of the array (up to 4 values). Can someone please assist me with this or point me in the right direction? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking array to see if value exists before adding to array
Sorry for the lack of information, I was running out the door as I was typing
it. Basically, I have a sheet which will holds a number of optional units which a student can select as part of an overall course. When a new persons name is added to a column on the sheet 4 mandatory courses are selected (by putting X in the column beside unit name). The user is then prompted with an inputbox to enter the code number of the selected unit. This then loops through the courses to find the selected unit and put an X in the corresponding box. The input box happens 4 times for 4 optional units. This all works OK at the moment, but allows the user to be able to enter the same course code 4 times, rather than removing the selected one from the options. I was trying to get option 1 stored into an array in element 1, then get option 2 to check if this is the same choice as option 1 and if not, store it in array element 2, then option 3 to check element 1 and 2 and so on... At the moment, my code (which I can post tomorrow if required - it's at work, I'm at home) does all of this but my lack of logic in my code has ment that where I have my check/add to array, it is adding each option to all of the array elements. Just wondering if anyone can help/point me in the direction of a bit of code that will check the array to see if the value already exists, and if not, add it to the next element. Hope this makes a lot more sense, now that I have time to type a bit more in depth. Thanks "Rick Rothstein" wrote: I think we need some more information. Where is this list of possible entries at... In a declared VB array? In a range of cells? In a String variable? Somewhere else? Also, what do you mean by "the already entered value of an array"... is that an array of cells or a declared VB array? -- Rick (MVP - Excel) "Wullie" wrote in message ... Hi, I am going round in circles as usual and am doing (at least) one stupid thing with a lack of logic, so need some help. I have a list of possible entries that someone can manually enter, which I then want to check against already entered values of an array and then if it's not in the array to add it to the next value of the array (up to 4 values). Can someone please assist me with this or point me in the right direction? Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking array to see if value exists before adding to array
Yes, I think it would be helpful if you posted your code.
-- Rick (MVP - Excel) "Wullie" wrote in message ... Sorry for the lack of information, I was running out the door as I was typing it. Basically, I have a sheet which will holds a number of optional units which a student can select as part of an overall course. When a new persons name is added to a column on the sheet 4 mandatory courses are selected (by putting X in the column beside unit name). The user is then prompted with an inputbox to enter the code number of the selected unit. This then loops through the courses to find the selected unit and put an X in the corresponding box. The input box happens 4 times for 4 optional units. This all works OK at the moment, but allows the user to be able to enter the same course code 4 times, rather than removing the selected one from the options. I was trying to get option 1 stored into an array in element 1, then get option 2 to check if this is the same choice as option 1 and if not, store it in array element 2, then option 3 to check element 1 and 2 and so on... At the moment, my code (which I can post tomorrow if required - it's at work, I'm at home) does all of this but my lack of logic in my code has ment that where I have my check/add to array, it is adding each option to all of the array elements. Just wondering if anyone can help/point me in the direction of a bit of code that will check the array to see if the value already exists, and if not, add it to the next element. Hope this makes a lot more sense, now that I have time to type a bit more in depth. Thanks "Rick Rothstein" wrote: I think we need some more information. Where is this list of possible entries at... In a declared VB array? In a range of cells? In a String variable? Somewhere else? Also, what do you mean by "the already entered value of an array"... is that an array of cells or a declared VB array? -- Rick (MVP - Excel) "Wullie" wrote in message ... Hi, I am going round in circles as usual and am doing (at least) one stupid thing with a lack of logic, so need some help. I have a list of possible entries that someone can manually enter, which I then want to check against already entered values of an array and then if it's not in the array to add it to the next value of the array (up to 4 values). Can someone please assist me with this or point me in the right direction? Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Checking array to see if value exists before adding to array
Thanks for the offer of help Rick.
I changed my code and instead of the user entering values into an input box, I created a userform with a list of all units and got the user to select/deselect the required ones, then read the selection out of the list back into the main code to populate the required boxes with an "X". Again, thanks anyway "Rick Rothstein" wrote: Yes, I think it would be helpful if you posted your code. -- Rick (MVP - Excel) "Wullie" wrote in message ... Sorry for the lack of information, I was running out the door as I was typing it. Basically, I have a sheet which will holds a number of optional units which a student can select as part of an overall course. When a new persons name is added to a column on the sheet 4 mandatory courses are selected (by putting X in the column beside unit name). The user is then prompted with an inputbox to enter the code number of the selected unit. This then loops through the courses to find the selected unit and put an X in the corresponding box. The input box happens 4 times for 4 optional units. This all works OK at the moment, but allows the user to be able to enter the same course code 4 times, rather than removing the selected one from the options. I was trying to get option 1 stored into an array in element 1, then get option 2 to check if this is the same choice as option 1 and if not, store it in array element 2, then option 3 to check element 1 and 2 and so on... At the moment, my code (which I can post tomorrow if required - it's at work, I'm at home) does all of this but my lack of logic in my code has ment that where I have my check/add to array, it is adding each option to all of the array elements. Just wondering if anyone can help/point me in the direction of a bit of code that will check the array to see if the value already exists, and if not, add it to the next element. Hope this makes a lot more sense, now that I have time to type a bit more in depth. Thanks "Rick Rothstein" wrote: I think we need some more information. Where is this list of possible entries at... In a declared VB array? In a range of cells? In a String variable? Somewhere else? Also, what do you mean by "the already entered value of an array"... is that an array of cells or a declared VB array? -- Rick (MVP - Excel) "Wullie" wrote in message ... Hi, I am going round in circles as usual and am doing (at least) one stupid thing with a lack of logic, so need some help. I have a list of possible entries that someone can manually enter, which I then want to check against already entered values of an array and then if it's not in the array to add it to the next value of the array (up to 4 values). Can someone please assist me with this or point me in the right direction? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) | Excel Programming | |||
VLOOK up returning #N/A even though value exists in lookup array | Excel Worksheet Functions | |||
If worksheet from array exists then not working | Excel Programming | |||
Lookup value - see if exists in another array | Excel Worksheet Functions | |||
need array of true/false if text exists | Excel Worksheet Functions |