PDA

View Full Version : New to VBA



james620
11-07-2009, 07:07 AM
Hello can someone help me? Its probably really simple, so i apologise

I first came across VBA yesterday and have been using it to create macros in VBA for exel documents I use.. Im still very much a newbie !!

I have written one (but it doesn't work yet!!),

I need to get it to look at a list of names. There are 6 names in each column, split into 2 groups of 3 names each. I want the macro to look each set of 3 and compare them to another list of names. if there is a match then it has 2 boxes below this, one for each set of 3. If there is a postitve match it says yes, then if not then no.... It then completes this for every column, starting at H going up to GZ

Simple? Or confused? I am !!

p45cal
11-07-2009, 10:44 AM
Attach an example workbook. Without it there are too many unknowns:
'split into 2 groups of 3 names each' split by blank rows? or split top3/bottom3?
'to another list of names' what list of names?
'if there is a match' an exact match or a partial match?
'it has 2 boxes below this' are we talking textboxes here? or just cells.
'If there is a postitve match' what makes a positive match? All three names have to match or just one?

Also post what code you've got so far - we can often glean a fair amount from that.

james620
11-07-2009, 10:52 AM
The top 3 are days, and the bottom 3 are nights, basically i want to ensure one of the top 3 is a driver, i have a list of drivers to compare it to. if one of the names are then i want it to put a yes or something similar in the cells below. the same for the nights one

Bob Phillips
11-07-2009, 12:32 PM
Where is the list of drivers?

What about the bottom 3?

james620
11-07-2009, 12:41 PM
Where is the list of drivers?

What about the bottom 3?


The list is on a different sheet as a nominal role of all the people. i want it to evaluate the top 3 and tell me in a cell underneath the yes or no, and then evaluate the bottom 3 and then display the result in the next cell below... ?

Here is a better example attached

p45cal
11-07-2009, 01:17 PM
You haven't shown us the code you've written.

But you don't need vba to do this.
This is the first thing I thought of, so it may not be terribly elegant, but I created a Named Range Drivers on sheet 2 and used formulae like this:
=IF(SUM(COUNTIF(Drivers,B$1),COUNTIF(Drivers,B$2),COUNTIF(Drivers,B$3))>0,"Yes","No")
See attached to see it working.

james620
11-07-2009, 03:13 PM
Thank you that works a treat !!