Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Columns
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Columns
On Oct 15, 1:20*pm, Paul Black wrote:
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Columns
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 "Paul Black" wrote in message ... On Oct 15, 1:20 pm, Paul Black wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Columns
On Oct 15, 2:24*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote: 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 "Paul Black" wrote in message ... On Oct 15, 1:20 pm, Paul Black wrote: 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 Thanks Bernie, It works brilliantly! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Make Columns A&B on Sheet2 always equal Sheet1 table columns A&B | Setting up and Configuration of Excel | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
Combine multiple columns into two long columns, Repeating rows in first column | Excel Discussion (Misc queries) | |||
Excel 2007 extra columns - but transposing columns still not working! | Excel Programming | |||
Excel button :: Filter columns by value - possible? Additionally, hide certain columns | Excel Programming |