Hello to all,
Clicking on button Player Draw I would like to bring in the third card and if I choose to click again and bring in the fourth card.
I'm thinking of using multiple IF's ... is there an easier way?
Here is the file and thank you.
Hello to all,
Clicking on button Player Draw I would like to bring in the third card and if I choose to click again and bring in the fourth card.
I'm thinking of using multiple IF's ... is there an easier way?
Here is the file and thank you.
Last edited by ndendrinos; 12-10-2006 at 08:07 PM. Reason: cannot attach file
Thank you for your help
I created two macros, based on the ones in the workbook you provided.
They are called NewDeal and NewPlayer. I kept the old macros, but reassigned the buttons to the new ones. Deal is enhanced by randomization, i.e. not the same cards come in, always. Player is enhanced according to your request.
Also, I put all macros to one code module, and deleted excess modules in the hope of reducing filesize, as the file was too large to upload.
Jimmy
Hello Jimmy, sorry was tied up yesterday . Had a quick look at your revision and it looks great... will test it further and post back.
Thank you very much.
Nick
Thank you for your help
JimmyTheHand came up with this code and it works great. Why I need to do is change the range from columnA to columnB Tried editing to no avail ... can someone point out the line that defines this range? (Not C:M) Thank you and here is the code:
[vba]Sub NewDeal()
Application.ScreenUpdating = False
Dim Rng As Range
Dim Sh As Shape
Dim ws As Worksheet
Dim Counter As Long, Serial As Long
Set ws = Worksheets("Sheet1")
Set Rng = ws.Range("C1:M1")
For Each Sh In ws.Shapes
If Not Intersect(Sh.TopLeftCell, Rng) Is Nothing Then Sh.Delete
Next Sh
For Counter = 0 To 1
Serial = Int(Rnd(1) * 9) + 866
ActiveSheet.Shapes("Picture " & CStr(Serial)).Copy
Cells(1, Counter + 3).Select
ActiveSheet.Paste
Next
Set Rng = Nothing
Set ws = Nothing
Application.ScreenUpdating = True
End Sub[/vba]
Thank you for your help
move the count to column B?
not sure what's going on here but it's probably in this line:
[VBA]Cells(1, Counter + 3).Select[/VBA]
try changing the 1 to a 2
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Hello lukas, tried that one and others before posting and nothing works ...any other idea? Could be that Jimmy's code does not use the columns A&B to randomize But ratefr uses only one (ColumnA) Here is the other code that completes Jimmy's contribution to my posting:
[vba]Sub NewPlayer()
Application.ScreenUpdating = False
Dim Rng As Range
Dim Sh As Shape
Dim ws As Worksheet
Dim Counter As Long, Serial As Long
Set ws = Worksheets("Sheet1")
Set Rng = ws.Range("C1:M1")
Counter = 0
For Each Sh In ws.Shapes
If Not Intersect(Sh.TopLeftCell, Rng) Is Nothing Then Counter = Counter + 1
Next Sh
If (Counter > 1) And (Counter < 6) Then
Serial = Round(Rnd(1) * 9) + 866
ActiveSheet.Shapes("Picture " & CStr(Serial)).Copy
Cells(1, Counter + 4).Select
ActiveSheet.Paste
End If
Set Rng = Nothing
Set ws = Nothing
Application.ScreenUpdating = True
End Sub
[/vba]
Last edited by ndendrinos; 12-14-2006 at 10:57 AM.
Thank you for your help
Can you be a little more specific......what is happening in col A that you wish to change?
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Difficult to describe ... In column A in have in order 52 palying cards I run the macro "Deal" and the cards are shuffled randomly in column B.
When I draw a card I need to draw it from column B starting at B3 ... Is there a way to apply this logic to Jimmy's code ... need an extra minute to edit my reply before this one as I inserted the wrong code that completes Jimmy's contribution .. Thanks Steve
Thank you for your help
Got it now.. Jimmy uses Column A only ... no wonder I had a problem ... So now after testing his code I do see duplicates ... Can I then come back to my initial question and that is:
I need to use a single button to do this:
Click button first time and select B3
Click that button again and select B4
Again and select B5 ... etc
Thank you
Thank you for your help
Guys,
I used a completely defferent approach.
When I experimentally listed the names of all the shapes (actually, the cards), I found that they are called "Picture 886", "Picture 887", etc. and there are 9 of them. So when I select the card to be displayed next, I refer to them directly by name using this code:
[vba] Serial = Round(Rnd(1) * 9) + 866
ActiveSheet.Shapes("Picture " & CStr(Serial)).Copy[/vba] where Serial is the random number (886 through 874),
"Picture " & CStr(Serial) is the name of the picture (Picture 886 ... to Picture 874)
Best,
Jimmy
Edit:
Oops..
I made errors in the post. Instead of 886 and 887, 866 and 867 should have been used. Sorry if this was cause of any confisuon.
Last edited by JimmyTheHand; 12-15-2006 at 01:15 AM.
-------------------------------------------------
The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.
Thanks Jimmy for the explanation ... I'm sure it will work this time
Best regards,
Nick
Thank you for your help