Jul 28 2020 09:47 AM - edited Jul 28 2020 10:02 AM
I keep Having errors with the below code
Public TheDeck As Worksheet
Public TheTable As Worksheet
Public NextCard as Range
Public Hitlocation as Range
Public NumberCardInhand as Interger
Public NumberCardInDeck as Interger
Set TheDeck = Thisworkbook.Sheets("Deck")
Set TheTable = Thisworkbook.Sheets("Table")
NumberCardInHand = 1
NumberCardinDeck =1
Set NextCard = TheDeck.Range("A" & NumberCardInDeck + 1)
Set HitLocation = TheTable.Range("H" & (NumberCardInHand + 23))
Do until NumberCardinHand = 2
HitLocation.value = NextCard.value
NumberCardinHand = NumberCardInHand + 1
NumberCardInDeck = NumberCardInDeck + 1
Loop
There is more code around this but this is the applicable part. This code Works perfect for the first iteration of the loop But t holds the original value of "NextCard" + "HitLocation" indefinitely and doesnt update them if the values they are dependent on change. is that normal and are there any workarounds?
Jul 28 2020 12:50 PM
You'd have to move the lines
Set NextCard = TheDeck.Range("A" & NumberCardInDeck + 1)
Set HitLocation = TheTable.Range("H" & (NumberCardInHand + 23))
inside the loop.