Goalexcel
Board Regular
- Joined
- Dec 28, 2020
- Messages
- 101
- Office Version
- 2016
- Platform
- Windows
I have searched to find out how to modify the below code to help me to:
- Copy those number from column A until column I no exactly number of columns, and also the same no exactly number of rows. Data is sheet 1 until sheet 8 no exactly the sheets.
- Copy those 4 continuous numbers to all down column A. maybe A25. Highlight those number colors.
- Once use input box asking how many numbers I can enter 4 numbers to pick up.
- Next copy more numbers until is full copy. No duplicates once choose the numbers See below image need the result.
-
- This is the code that need to change
-
VBA Code:
Sub CopySequenceNumberFromColumn() Dim HowMany As Long, Cnt As Long, RandomIndex As Long Dim Tmp As Variant, Number As Variant HowMany = 4 Number = Range("A1", Cells(Rows.Count, "A").End(xlUp)) Randomize For Cnt = 1 To UBound(Number) RandomIndex = Int(Cnt * Rnd + 1) Tmp = Number(RandomIndex, 1) Number(RandomIndex, 1) = Number(Cnt, 1) Number(Cnt, 1) = Tmp Next Range("A25").Resize(HowMany) = Number End Sub