Excel Formula to keep records of drawn cards

Cquake

Board Regular
Joined
Dec 12, 2017
Messages
60
Office Version
  1. 2016
Platform
  1. Windows
In my excel sheet "home" cell A21 I have a card value number that comes up when activated by a macro that generates a new number that I would like to have those recorded in the order in which they are drawn in the same sheet "home" but from cells K1:Z40. Columns K,M,O,Q,S,U,W,Y are all pre-numbered to represent the draw number. IE: Colum K1:K40 would be listed as 1 to 30, Column M1 to M30 would be draw numbers 31 - 60, etc etc. Columns L,N,P,R,T,V,X,Z would be the the value of that draw. Any duplicate numbers drawn would show in bold red so I can spot how many times a number may be re-generated. Once all 240 cells have been filled a macro would be used to clear the current data and begin again. My question is what formula would be needed to accomplish this or is there a VBA code that would automatically accomplish this without the use of a macro activating it? As stated earlier the card value originates from A21. Any help would be appreciated.

K...........................L.............M.............N............O................P..............Q........................R.............S........................T............U.........................V..........W...........................X............Y..........................Z
1316191121151181211
2326292122152182212
3336393123153183213
4346494124154184214
5356595125155185215
6366696126156186216
7376797127157187217
8386898128158188218
9396999129159189219
104070100130160190220
114171101131161191221
124272102132162192222
134373103133163193223
144474104134164194224
154575105135165195225
164676106136166196226
174777107137167197227
184878108138168198228
194979109139169199229
205080110140170200230
215181111141171201231
225282112142172202232
235383113143173203233
245484114144174204234
255585115145175205235
265686116146176206236
275787117147177207237
285888118148178208238
295989119149179209239
306090120150180210240
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
There's probably a better way to write this (I'm not a VBA expert).
Ideally the quickest way to do this is to populate 2 cells with the last cell row and number (ie keep track of the blank cell that was last filled) and increment the row/column.

This code should be placed within your existing macro AFTER A21 is populated with a new card.

Code:
' Clear columns if fully populated
If Worksheets("Home").Range("Z40") <> "" Then
Range("L1:L40").Clear
Range("N1:N40").Clear
Range("P1:P40").Clear
Range("R1:R40").Clear
Range("T1:T40").Clear
Range("V1:V40").Clear
Range("X1:X40").Clear
Range("Z1:Z40").Clear
End If
' Find next available blank cell, exit from loop when found
For i = 12 To 26 Step 2
For j = 1 To 40
If Worksheets("Home").Cells(j, i) = "" Then
i1 = i: j1 = j: i = 27: j = 41
End If
Next j
Next i
' Populate the blank cell with the contents of A21
Worksheets("Home").Cells(j1, i1) = Worksheets("Home").Cells(21, 1)
 
Upvote 0
For Conditional formatting. Select L1.
Formula
Excel Formula:
=SUMPRODUCT(1*(($L$1:$Z$30<>"")*($L$1:$Z$30=L1)*ISODD(COLUMN($L$1:$Z$1)-COLUMN($K$1))))>1
Select Font and Red Color.
Copy the format of Li to the full required range.
For Erasing Data after complete fill up use the worksheet event below.
Code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("L1:Z30")) Is Nothing Then
Dim T&
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Application.CountBlank(Range("L1:Z30")) = 0 Then
For T = 0 To 7
Range("L1:L30").Offset(0, T * 2).ClearContents
Next T
Application.EnableEvents = True
End If
End If
End Sub
How to use worksheet event the code
Right click on Sheet tab --> view code
Visual Basic (VB) window opens.
Paste the code
Close the VB window.
Save the file as .xlsm
 
Upvote 0

Forum statistics

Threads
1,223,881
Messages
6,175,159
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top