Hey Guys
This is the proble i have at the moment i created a mini game that has a cell that changes when the macro is run.
I would like to copy the cell value when it has changed to a new cell.
So for instance:
A17 = W Then C1 = W
A17 = L Then C2 = L
A17 = L Then C3 = L
A17 is changing via a formula based on many other formulas and their results so its not a direct change by myself.
I tried to implement this macro:
But it Just copied A17 2000 times which is obviously not what i want.
My Main Macro is:
I dont know much about VBA infact very little and all my code was found online that i just edited for my needs.
Thanks alot for any help
Edit* if i need to attach my spreadsheet i can as the formulas i have are not located in the VBA but done manually on the sheet itslef
This is the proble i have at the moment i created a mini game that has a cell that changes when the macro is run.
I would like to copy the cell value when it has changed to a new cell.
So for instance:
A17 = W Then C1 = W
A17 = L Then C2 = L
A17 = L Then C3 = L
A17 is changing via a formula based on many other formulas and their results so its not a direct change by myself.
I tried to implement this macro:
Code:
Sub Macro
Dim i As Long
For i = 1 To 2000
Range("A1").Calculate
Range("B1").Offset(i - 1).Value2 = Range("A1").Value2
Next i
End Sub
But it Just copied A17 2000 times which is obviously not what i want.
My Main Macro is:
Code:
Sub Poker_Coll()
'Uses a collection not a dictionary
Dim NumCards As Integer, Players As Integer
Dim Suits(), Cards()
Dim J As Variant, K As Variant
Dim CardNum As Integer, i As Integer, v As Integer, CardPick As Integer
Dim Casino As Collection, CardName As String
Dim NewSheet As Worksheet
Set Casino = New Collection
' number of cards
NumCards = 3
' number of players
Players = 2
If NumCards * Players > 52 Then
MsgBox "You have exceeded one deck!", vbCritical
Exit Sub
End If
Application.ScreenUpdating = False
'Add a new sheet for the game
'Set NewSheet = ActiveWorkbook.Sheets.Add
'Requires Excel 2000+ to use Array
Suits = Array("", "", "", "")
Cards = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", _
"0", "Jack", "Queen", "King")
' Add the cards to the Collection
i = 1
For Each J In Suits
For Each K In Cards
Casino.Add K & "" & J
i = i + 1
Next K
Next J
'Pick a random card, deal it and remove it from the pack
For i = 1 To Players
ActiveSheet.Cells(1, i) = "Player " & i
For v = 1 To NumCards
CardPick = Int(Rnd() * Casino.Count + 1)
CardName = Casino(CardPick)
ActiveSheet.Cells(v + 1, i) = CardName
Casino.Remove (CardPick)
Next v
Next i
'dump undealt cards
v = 1
ActiveSheet.Cells(v, i + 1) = "Undealt Cards"
For Each J In Casino
v = v + 1
ActiveSheet.Cells(v, i + 1) = J
Next J
ActiveSheet.UsedRange.EntireColumn.AutoFit
Application.ScreenUpdating = True
Set Casino = Nothing
End Sub
I dont know much about VBA infact very little and all my code was found online that i just edited for my needs.
Thanks alot for any help
Edit* if i need to attach my spreadsheet i can as the formulas i have are not located in the VBA but done manually on the sheet itslef
Last edited: