VBA code Copy sequence of numbers in different rows without duplicate

Goalexcel

Board Regular
Joined
Dec 28, 2020
Messages
101
Office Version
  1. 2016
Platform
  1. Windows
I have searched to find out how to modify the below code to help me to:

  1. 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.
  2. Copy those 4 continuous numbers to all down column A. maybe A25. Highlight those number colors.
  3. Once use input box asking how many numbers I can enter 4 numbers to pick up.
  4. Next copy more numbers until is full copy. No duplicates once choose the numbers See below image need the result.
  5. 1637374203123.png
  6. This is the code that need to change
  7. 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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

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