Solved

Putting an 'X' for each number in specific cells

Posted on 2014-01-16
3
228 Views
Last Modified: 2014-01-16
Ok so this may seem like a weird request but we run an office pool and I want to automate it. I've attached a sample of the pool that we currently use. So here's how it works:

You enter the daily lottery number in the cells from D16 thru AB22 in the columns that say "Number". It corresponds to the date the lottery number was drawn which is the dates right next to each column of number.

Then you put an 'X' for each digit that matches the numbers in the top section from C4 thru V13. When a person reaches 20 numbers for their number they win the pool.

What I want to automate is when you type the numbers in the bottom section I want it to automatically put the 'X' in each cell in the top section. So if the number was 9511 I want it to put an 'X' in cell C12 for the 9, then an 'X' in cell C8 for the 5, and then X's in cells C4 and D4 for each of the 1's. And then continue on to the right till they reach 20 numbers. How can I automate this using VBA code so when I type in the number in the bottom section it will look at the top section and keep putting X's in each row for that number till it reaches 20 numbers?

In the sample I've attached it shows the current pool with the X's already loaded in the top section based on the numbers drawn below.
Lottery-Pool-Template.xlsx
0
Comment
Question by:Lawrence Salvucci
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
Steve earned 500 total points
ID: 39785161
OK the attached file does what you need.

The numbers range has been given a named range "NUMBERS" found in Formulas > 'Name Manager'.
This is fed into the custom UDF below in the last column:
Function NumbersCount(NumberLook As String, NumberRange As Range)

For Each c In NumberRange.Cells
    NumbersAll = NumbersAll & c.Value
Next c

x = Split(NumbersAll, NumberLook)
NumbersCount = UBound(x)

End Function

Open in new window


Then the IF statement takes care of the 'X'.

If you need further explanation let me know.
Lottery-Pool-Template.xlsm
0
 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
ID: 39785174
Thank you very much for your quick response! It works perfect! Thank you again!
0
 
LVL 24

Expert Comment

by:Steve
ID: 39785210
The attached workbook... on the second tab... does it all without the UDF.
So just with formulas.
Lottery-Pool-Template.xlsm
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now