Author Topic: Need quick Excel/VBA scripting help  (Read 1029 times)

InCreator

  • Posts: 3,168
  • Useless since 2003
    • I can help with AGS tutoring
    • I can help with animation
    • I can help with backgrounds
    • I can help with play testing
Need quick Excel/VBA scripting help
« on: 30 Dec 2011, 17:40 »


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?
« Last Edit: 30 Dec 2011, 17:41 by InCreator »

HandsFree

  • Posts: 350
    • I can help with making music
Re: Need quick Excel/VBA scripting help
« Reply #1 on: 31 Dec 2011, 15:58 »
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

  • Posts: 3,168
  • Useless since 2003
    • I can help with AGS tutoring
    • I can help with animation
    • I can help with backgrounds
    • I can help with play testing
Re: Need quick Excel/VBA scripting help
« Reply #2 on: 03 Jan 2012, 06:22 »
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.
« Last Edit: 03 Jan 2012, 06:24 by InCreator »

SSH

  • Posts: 5,710
  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on a game that won an AGS Award!
    •  
    • SSH worked on a game that was nominated for an AGS Award!
Re: Need quick Excel/VBA scripting help
« Reply #3 on: 03 Jan 2012, 08:18 »
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>)


Khris

  • Posts: 10,676
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: Need quick Excel/VBA scripting help
« Reply #4 on: 03 Jan 2012, 11:02 »
a = a+1

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

Calin Leafshade

  • Posts: 3,514
  • Long live King Cat!
    • I can help with making music
    • I can help with voice acting
    • Calin Leafshade worked on a game that won an AGS Award!
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
Re: Need quick Excel/VBA scripting help
« Reply #5 on: 03 Jan 2012, 13:25 »
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

  • Posts: 5,234
  • Return once more to the Two Kingdoms!
    • I can help with publishing
    • I can help with story design
    • Radiant worked on a game that won an AGS Award!
    •  
    • Radiant worked on a game that was nominated for an AGS Award!
Re: Need quick Excel/VBA scripting help
« Reply #6 on: 03 Jan 2012, 16:59 »
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