Hi everyone,
I couldn't find anything in the forum that could answer my question so here goes nothing...
I am recreating a table from an older board game that uses a slide rule to report numbers. During the game, the slide moves up and down according to what space you land on. However, if you hit the top of the table (e.g. You are at row #2 and the space says move Up 4), you move up 1 and then proceed to move back down 3 to fulfill the remaining spaces. I can code this by hand, but I really don't want to see how ugly the code gets when it's Move Up 20. Here's what I have so far:
ListBox1 contains the Values 1-5, and 20.
cmdUp is a toggle button (I also have a toggle button for down)
B20 contains what row number of the table the current selection is at.
B16 is what the prior value of the stock that needs to be changed. (The other stocks are coded to use VLookup to determine their values.)
I tried to think of an Algebraic way of approaching this, but I couldn't find something that would work universally.
Sorry for the noob post. And the game is "Stock Market" if that helps any.
Thank you in advance for any help.
Socaldwat
I couldn't find anything in the forum that could answer my question so here goes nothing...
I am recreating a table from an older board game that uses a slide rule to report numbers. During the game, the slide moves up and down according to what space you land on. However, if you hit the top of the table (e.g. You are at row #2 and the space says move Up 4), you move up 1 and then proceed to move back down 3 to fulfill the remaining spaces. I can code this by hand, but I really don't want to see how ugly the code gets when it's Move Up 20. Here's what I have so far:
ListBox1 contains the Values 1-5, and 20.
cmdUp is a toggle button (I also have a toggle button for down)
B20 contains what row number of the table the current selection is at.
B16 is what the prior value of the stock that needs to be changed. (The other stocks are coded to use VLookup to determine their values.)
Code:
Private Sub CmdOk2_Click()
Dim x As Integer
x = Range("B20").Value
Sheets("Stock Values").Select
If cmdUp.Value = True Then
If ListBox1.Value = 1 Then
If x <= "1" Then
ActiveCell.Offset(-1, 0).Select
Sheets("Game!").Range("B16").Value = Sheets("Stock Values").ActiveCell.Value
End If
ActiveCell.Offset(1, 0).Select
Sheets("Game!").Range("B16").Value = Sheets("Stock Values").ActiveCell.Value
End If
If ListBox1.Value = 2 Then
If x = "1" Then
ActiveCell.Offset(-2, 0).Select
Sheets("Game!").Range("B16").Value = Sheets("Stock Values").ActiveCell.Value
End If
ElseIf x = "2" Then
'This selection moves the table up one, and then down one, virtually doing nothing.
End If
Else
ActiveCell.Offset(2, 0).Select
Sheets("Game!").Range("B16").Value = Sheets("Stock Values").ActiveCell.Value
End if
End Sub
I tried to think of an Algebraic way of approaching this, but I couldn't find something that would work universally.
Sorry for the noob post. And the game is "Stock Market" if that helps any.
Thank you in advance for any help.
Socaldwat