Solved

Putting an 'X' for each number in specific cells

Posted on 2014-01-16
3
230 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

776 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