If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Find Missing Number fron Random List

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-11, 19:52
SRR SRR is offline
Registered User
 
Join Date: Dec 2009
Posts: 39
Question Find Missing Number fron Random List

Hi,

I have a schedule for shifts, and the teams are assigned these numbers:

1
2
3
4
5
9
11
13
14
15
17

I need to display in a cell (or list of cells) which team has not been scheduled that day. My spreadsheet is set up as a workshift calendar (with 50+ possible assignments aka rows), so I am thinking a formula would be best so that I could copy it over for each day of the week. Can anyone help? The first range of cells that would need to be searched would be B4:B64, with results of missing search displayed in B65(through B75 if need be).
Reply With Quote
  #2 (permalink)  
Old 07-09-11, 02:12
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

This is possible with formulas, but it's not an efficient way to do it. Your best bet is to write a small VBA procedure which will calculate the missing values and put them into the relevant range. Have you worked with VBA before?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 07-11-11, 11:56
SRR SRR is offline
Registered User
 
Join Date: Dec 2009
Posts: 39
I am familiar with VBA, I just wasn't aware that I could use it produce results in multiple columns. Any assistance you could provide would be appreciated. I am self taught on most code, so I am learning something new everyday :-)
Reply With Quote
  #4 (permalink)  
Old 07-11-11, 15:56
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Sure, please can you attach a sample workbook so we're working from the same starting point?
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #5 (permalink)  
Old 07-11-11, 18:42
SRR SRR is offline
Registered User
 
Join Date: Dec 2009
Posts: 39
I appreciate your assistance!
Attached Files
File Type: zip schedule draft.zip (9.8 KB, 12 views)

Last edited by SRR; 07-11-11 at 19:13.
Reply With Quote
  #6 (permalink)  
Old 07-12-11, 17:59
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
I've attached a formula solution.

In cells A67:A77 I've listed the distinct numbers which teams can be assigned per post #1.

Then I put this formula in B67:
Code:
=IF(SUM(COUNTIF(B$4:B$64,{""," ","*,","*, "}&$A67&{"";" ";",*";" ,*"})),"",$A67)
And then copied it down to B77 and across the columns for each date. This formula checks the schedule and counts how many times the "required number" appears. If it doesn't appear then it returns the required number, else it returns an empty string. This formula allows for a single space and comma separated lists within the cells (as per your attachment) so, if it was looking for the number 17, then all of these would be recognised (for the purposes of this post, I used _ to represent a space):
Code:
17
17_
17,
17_,
_17
_17_
_17,
_17_,
,17
,17_
,17,
,17_,
,_17
,_17_
,_17,
,_17_,
If you want me to explain the formula in more detail then just ask.


This leaves gaps in the blocks of cells where numbers have been found (see range B67:AC77). I wasn't sure if that was acceptable or not, so I hid them and then added another block underneath (see range B81:AC92) where the gaps are removed by using this formula:
Code:
=IF(COUNT(B$67:B$77)>=$A81,SMALL(B$67:B$77,$A81),"")
The values in A81:A92 are simply indexes. Obviously you can hide rows / format them however you want.

I'm not sure why you didn't have 11 listed as missing for 28th and 29th.
Attached Files
File Type: zip schedule draft.zip (16.3 KB, 7 views)
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA

Last edited by Colin Legg; 07-12-11 at 18:15.
Reply With Quote
  #7 (permalink)  
Old 07-12-11, 19:39
SRR SRR is offline
Registered User
 
Join Date: Dec 2009
Posts: 39
Thanks so much! The attachment won't unzip for me so I can't view the document, but I am following what you did for the formula and it makes total sense. I would not have thought to account for spaces or commas. I am trying to understand what you did after you hid the gaps, but I am sure once I plug the formula in it will make sense. Looks like I need to teach myself more about the IF and COUNTIF statements. (I am not sure why 11 was omitted either, but that was why we needed a formula!)

Thanks SO much, and if you are ever in the San Francisco area, I owe you a pint!
Reply With Quote
  #8 (permalink)  
Old 07-13-11, 06:23
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Glad it helped.

The index values in A81:A92 I referred to are just the numbers 1,2,3,4,5,6,7,8,9,10,11,12 (one number per cell)
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On