[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Putting an 'X' for each number in specific cells

Posted on 2014-01-16
3
Medium Priority
?
238 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 2000 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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

656 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