Help with Columns

P

Paul Black

Good afternoon,

This code worked fine until I inserted an extra column at the very
front of my data (column "A" is blank, added column "B", data now
starts in column "C" instead of column "B")
How can I change it so it still works although EVERYTHING has moved
one column to the right.
Thanks in advance.

Paul
 
P

Paul Black

Good afternoon,

This code worked fine until I inserted an extra column at the very
front of my data (column "A" is blank, added column "B", data now
starts in column "C" instead of column "B")
How can I change it so it still works although EVERYTHING has moved
one column to the right.
Thanks in advance.

Paul

Sorry, would help if I put the code ...

Option Explicit
Option Base 1

Sub Multiple_Combination_Checker_PAB()
Dim Start As Double
Start = Timer
Dim Bonus As Long
Dim CombinationDrawn As Range
Dim CombinationToCheck As Range
Dim Matched() As Long
Dim NonBonus As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Macro Program").Select

For Each CombinationToCheck In Range(Cells(8, 10), Cells(Rows.Count,
10).End(xlUp))
Erase Matched
ReDim Matched(0 To 7)
For Each CombinationDrawn In Range(Cells(8, 2), Cells(Rows.Count,
2).End(xlUp))
NonBonus = Evaluate("Sum(Countif(" & CombinationToCheck.Resize
(1, 6).Address & _
"," & CombinationDrawn.Resize(1, 6).Address & "))")
Bonus = Evaluate("Countif(" & CombinationToCheck.Resize(1,
6).Address & _
"," & CombinationDrawn.Offset(0, 6).Address & ")")
If NonBonus = 6 Then
Matched(7) = Matched(7) + 1
ElseIf NonBonus = 5 And Bonus = 1 Then
Matched(6) = Matched(6) + 1
Else
Matched(NonBonus) = Matched(NonBonus) + 1
End If
Next
CombinationToCheck.Offset(0, 7).Resize(1, 8).Value = Matched
Next

Range("A1").Value = Format(((Timer - Start) / 24 / 60 / 60),
"hh:mm:ss")

Range("B1519").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

.... Thanks, Paul
 
B

Bernie Deitrick

Sub Multiple_Combination_Checker_PAB()
Dim Start As Double
Start = Timer
Dim Bonus As Long
Dim CombinationDrawn As Range
Dim CombinationToCheck As Range
Dim Matched() As Long
Dim NonBonus As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Macro Program").Select

For Each CombinationToCheck In Range(Cells(8, 11), Cells(Rows.Count,
11).End(xlUp))
Erase Matched
ReDim Matched(0 To 7)
For Each CombinationDrawn In Range(Cells(8, 3), Cells(Rows.Count,
3).End(xlUp))
NonBonus = Evaluate("Sum(Countif(" & CombinationToCheck.Resize
(1, 6).Address & _
"," & CombinationDrawn.Resize(1, 6).Address & "))")
Bonus = Evaluate("Countif(" & CombinationToCheck.Resize(1,
6).Address & _
"," & CombinationDrawn.Offset(0, 6).Address & ")")
If NonBonus = 6 Then
Matched(7) = Matched(7) + 1
ElseIf NonBonus = 5 And Bonus = 1 Then
Matched(6) = Matched(6) + 1
Else
Matched(NonBonus) = Matched(NonBonus) + 1
End If
Next
CombinationToCheck.Offset(0, 7).Resize(1, 8).Value = Matched
Next

Range("A1").Value = Format(((Timer - Start) / 24 / 60 / 60),
"hh:mm:ss")

Range("B1519").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

--
HTH,
Bernie
MS Excel MVP


Good afternoon,

This code worked fine until I inserted an extra column at the very
front of my data (column "A" is blank, added column "B", data now
starts in column "C" instead of column "B")
How can I change it so it still works although EVERYTHING has moved
one column to the right.
Thanks in advance.

Paul

Sorry, would help if I put the code ...

Option Explicit
Option Base 1

Sub Multiple_Combination_Checker_PAB()
Dim Start As Double
Start = Timer
Dim Bonus As Long
Dim CombinationDrawn As Range
Dim CombinationToCheck As Range
Dim Matched() As Long
Dim NonBonus As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Macro Program").Select

For Each CombinationToCheck In Range(Cells(8, 10), Cells(Rows.Count,
10).End(xlUp))
Erase Matched
ReDim Matched(0 To 7)
For Each CombinationDrawn In Range(Cells(8, 2), Cells(Rows.Count,
2).End(xlUp))
NonBonus = Evaluate("Sum(Countif(" & CombinationToCheck.Resize
(1, 6).Address & _
"," & CombinationDrawn.Resize(1, 6).Address & "))")
Bonus = Evaluate("Countif(" & CombinationToCheck.Resize(1,
6).Address & _
"," & CombinationDrawn.Offset(0, 6).Address & ")")
If NonBonus = 6 Then
Matched(7) = Matched(7) + 1
ElseIf NonBonus = 5 And Bonus = 1 Then
Matched(6) = Matched(6) + 1
Else
Matched(NonBonus) = Matched(NonBonus) + 1
End If
Next
CombinationToCheck.Offset(0, 7).Resize(1, 8).Value = Matched
Next

Range("A1").Value = Format(((Timer - Start) / 24 / 60 / 60),
"hh:mm:ss")

Range("B1519").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

.... Thanks, Paul
 
P

Paul Black

Sub Multiple_Combination_Checker_PAB()
Dim Start As Double
Start = Timer
Dim Bonus As Long
Dim CombinationDrawn As Range
Dim CombinationToCheck As Range
Dim Matched() As Long
Dim NonBonus As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Macro Program").Select

For Each CombinationToCheck In Range(Cells(8, 11), Cells(Rows.Count,
11).End(xlUp))
    Erase Matched
    ReDim Matched(0 To 7)
    For Each CombinationDrawn In Range(Cells(8, 3), Cells(Rows.Count,
3).End(xlUp))
        NonBonus = Evaluate("Sum(Countif(" & CombinationToCheck..Resize
(1, 6).Address & _
            "," & CombinationDrawn.Resize(1, 6).Address & "))")
        Bonus = Evaluate("Countif(" & CombinationToCheck.Resize(1,
6).Address & _
            "," & CombinationDrawn.Offset(0, 6).Address & ")")
        If NonBonus = 6 Then
            Matched(7) = Matched(7) + 1
        ElseIf NonBonus = 5 And Bonus = 1 Then
            Matched(6) = Matched(6) + 1
        Else
            Matched(NonBonus) = Matched(NonBonus) + 1
        End If
    Next
    CombinationToCheck.Offset(0, 7).Resize(1, 8).Value = Matched
Next

Range("A1").Value = Format(((Timer - Start) / 24 / 60 / 60),
"hh:mm:ss")

Range("B1519").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

--
HTH,
Bernie
MS Excel MVP






Sorry, would help if I put the code ...

Option Explicit
Option Base 1

Sub Multiple_Combination_Checker_PAB()
Dim Start As Double
Start = Timer
Dim Bonus As Long
Dim CombinationDrawn As Range
Dim CombinationToCheck As Range
Dim Matched() As Long
Dim NonBonus As Long

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Sheets("Macro Program").Select

For Each CombinationToCheck In Range(Cells(8, 10), Cells(Rows.Count,
10).End(xlUp))
    Erase Matched
    ReDim Matched(0 To 7)
    For Each CombinationDrawn In Range(Cells(8, 2), Cells(Rows.Count,
2).End(xlUp))
        NonBonus = Evaluate("Sum(Countif(" & CombinationToCheck..Resize
(1, 6).Address & _
            "," & CombinationDrawn.Resize(1, 6).Address & "))")
        Bonus = Evaluate("Countif(" & CombinationToCheck.Resize(1,
6).Address & _
            "," & CombinationDrawn.Offset(0, 6).Address & ")")
        If NonBonus = 6 Then
            Matched(7) = Matched(7) + 1
        ElseIf NonBonus = 5 And Bonus = 1 Then
            Matched(6) = Matched(6) + 1
        Else
            Matched(NonBonus) = Matched(NonBonus) + 1
        End If
    Next
    CombinationToCheck.Offset(0, 7).Resize(1, 8).Value = Matched
Next

Range("A1").Value = Format(((Timer - Start) / 24 / 60 / 60),
"hh:mm:ss")

Range("B1519").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

... Thanks, Paul

Thanks Bernie,

It works brilliantly!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top