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
Solved

Putting an 'X' for each number in specific cells

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
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…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

856 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