Need quick Excel/VBA scripting help

Started by InCreator, Fri 30/12/2011 17:40:07

Previous topic - Next topic

InCreator



Thing is like this. There's a a sports event. Marathon or track run or whatever.
Every contestant has name (or number, as on picture) and amount of laps done under corresponding column.

What I want to do is that every time contestant finishes a lap, you can just type his number somewhere (say, a query window opens where you can enter his number or whatever) and automatically "laps" count under correct contestant number will increase.

The list of contestants could be very long so it would be too time consuming to find correct contestant by hand every time lap is finished, that's why this system should work in such quicker way. I know it's basically "hello world" in any other programming language, but I'm not too familiar with scripting in VBA and no time to learn it enough to be. And they demand it'd work in excel.

Can anyone help?

HandsFree

I'm no way an expert but this should be possible (I tried it a bit and I could at least update a cell using input commands).
If you're going to really use it during a sports event it has to be very robust though.
When do you need this?

InCreator

#2
Well, after few hours, I managed to make this myself with few lines of code. VBA is quite terrible compared to other programming languages (I honestly didn't remember such loose syntax and downright absurd mathematical operations from QBasic days... a = a+1, seriously?), but eventually I got what I needed.

SSH

You could just enter the contestant number in a big long column every time they pass the start (one row each time a new contestant passes) and then use =COUNTIF(B:B, <contestant no>)

12

Khris

Quote from: InCreator on Tue 03/01/2012 06:22:02a = a+1

What's wrong with that? Isn't that how pretty much every other language does it, too?

Calin Leafshade

a = a + 1 is perfectly valid syntax in pretty much every language i know of.

Remember that the = sign is *not* an equals sign. It is the assignment operator.

In fact older BASIC style languages use the keyword LET which is a more mathematical way of writing it.

Radiant

Quote from: Calin Leafshade on Tue 03/01/2012 13:25:46
a = a + 1 is perfectly valid syntax in pretty much every language i know of.

The entire C family of languages (which includes Java, PHP, and AGS) uses = for assignment and == for comparison. Pascal uses : = for assignment and = for comparison. BASIC is confusing in that it uses = for both.

At any rate, yes, this is one reason why math majors tend not to like CS majors. Another is that CS grads make much more money :P

SMF spam blocked by CleanTalk