Solved

Putting an 'X' for each number in specific cells

Posted on 2014-01-16
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

707 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