This site requires JavaScript, please enable it in your browser!
Greenfoot back
Game/maniac
Game/maniac wrote ...

2013/4/1

POLL INFO COLLECTION

1
2
danpost danpost

2013/4/3

#
Yes, but that would require a bit of doing.
danpost danpost

2013/4/3

#
@Game/maniac, a spreadsheet macro is a set of OOP instructions (usually in the Visual Basic language) that can automatically performs operations on the spreadsheet (move/delete/copy data, enter data into cells, iterate through cells, perform data comparisons, insert/delete cells etc.; basically anything you can do manually, plus more). Microsoft Excel usually comes with some macro creating capabilities. You can even 'record' keystrokes (or operations performed), which creates a macro; then, replaying the macro will repeat the steps you recorded. You can open the macro code and edit it to accomplish more than just what you can do manually. For my Poll Taker scenario, I click on the 'get data' link and select 'Open', which opens Excel and shows me the UserInfo data within a spreadsheet. Then, I copy/paste the String section only into my pre-made voting parser spreadsheet. Finally, I press Control-t, which runs my macro, and I get my list of options and final scorings, ready-made. In the process, the macro, goes through the selections made. Any selection not come across yet will be added to the final list and the selections will be searched for all instances of that selection, adding its scores to a variable as it finds them; and saves the final score for that selection in the list. Once all the selections have been exhausted, I have my final listing of scores.
Game/maniac Game/maniac

2013/4/3

#
How do you make a macro on a mac
danpost danpost

2013/4/3

#
Below is the macro I wrote for the voting parser spreadsheet. After copy/pasting the String portion of the UserInfo data to the spreadsheet at cell "A1" (the top-left cell of the spreadsheet), I run the macro.
Sub Tabulate()
    Columns("A:C").Select // will insert 3 new columns here
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("D1").Select // top-left of data is now at cell "D1"
    Selection.CurrentRegion.Select // selects the UserInfo String data block
    datablock = Selection.Address // saves the address of the block
    optionCount = 0 // initialize count of options listed in scoring table
    For voter = 0 To Selection.Rows.Count - 1 // for each voter
        For tier = 0 To 4 // for each selection by that voter
            option = Range(datablock).Cells(voter * 5 + tier) // get option name
            If option = Null Then
            ElseIf option = "" Then
            Else // option was found
                optionPoints = 0 // initial points for option
                For Each cell In Range(datablock) // for each entry in block
                    If cell = option Then
                        optionPoints = optioinPoints + 9 - cell.Column // add score
                        cell.Cells(1).Value = "" // remove selection from block
                    End If
                Next cell
                Range("A1").Offset(optionCount).Cells(1).Value = option // add option to scoring list
                Range("A1").Offset(optionCount, 1).Cells(1).Value = optionPoints // add score to list
                optionCount = optionCount + 1 // increment count of listed scores
            End If
        Next tier
    Next voter
End Sub
danpost danpost

2013/4/3

#
Game/maniac wrote...
How do you make a macro on a mac
I do not know. Does your spreadsheet program allow you to record operations and play them back?
Game/maniac Game/maniac

2013/4/3

#
Don't know
danpost danpost

2013/4/4

#
Added code at the end of the macro to sort the list of scores from highest points to lowest.
You need to login to post a reply.
1
2