Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-08-2025, 12:08 PM
p45cal's Avatar
p45cal p45cal is offline variations by using 5 of 6 different values Windows 10 variations by using 5 of 6 different values Office 2021
Expert
 
Join Date: Apr 2014
Posts: 962
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

This is specific for 5 chosen out of 6 possibles:
Code:
Sub blah()
x = "ABCDEF"
y = Len(x)
Count = Application.WorksheetFunction.Permut(y, 5)
Set Destn = ActiveCell
ReDim Results(1 To Count, 1 To 1)
idx = 0
ReDim result(1 To 5)
For a = 1 To y
  result(1) = Mid(x, a, 1)
  For b = 1 To y
    If b <> a Then
      result(2) = Mid(x, b, 1)
      For c = 1 To y
        If c <> a And c <> b Then
          result(3) = Mid(x, c, 1)
          For d = 1 To y
            If d <> a And d <> b And d <> c Then
              result(4) = Mid(x, d, 1)
              For e = 1 To y
                If e <> a And e <> b And e <> c And e <> d Then
                  result(5) = Mid(x, e, 1)
                  idx = idx + 1
                  Results(idx, 1) = Join(result, "")
                End If
              Next e
            End If
          Next d
        End If
      Next c
    End If
  Next b
Next a
Destn.Resize(idx) = Results
End Sub
It's clunky but it should run fast. Results are output to the active cell and the 719 cells below it.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to match values in one column to values in six others and return the value of a cell from corre SnakeDoctor Excel 4 09-09-2024 12:55 PM
variations by using 5 of 6 different values VBA to identify alpha numeric values in a word document and create a list of those values olson.jacob720 Word VBA 0 04-18-2022 10:44 AM
Table with values from several locations and years - need to find comp values Ricardo Sousa Excel 9 07-27-2018 02:06 AM
variations by using 5 of 6 different values Table with values from several locations and years - need to find comp values Ricardo Sousa Excel 6 06-09-2018 10:51 PM
finding variations in the data base adryan Excel 4 07-15-2015 12:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft