Good afternoon, I’m trying to automate a job that seems to have defeated the way we previously did it. Basically we get sample on a weekly basis and allocate flags to excluded records based on various criteria within the data – but only one flag per record. At present we run code that puts formulae in each row of each ‘exclusion reason’ column, Autofill all of them to the end of the column, calculate the sheet, do the next & finally copy the cells with formulae & paste as values. This (still) works fine on a weekly basis with some 3,000 records x 120 columns (16 of which are the ‘exclusion flag’ columns) but not when aggregating 9 months – around 112,000 records x 120 columns – either my PC or Excel doesn’t appear to be able to cope.
So, having written this question so far I’ve decided to break it down so we handle and complete only one column at a time now.
This has just taken around 100 seconds to execute. So far, so good. Now, unfortunately, the reasons for exclusion columns don’t run in the same order that the exclusions are processed so some of the formulae just look a bit clunky :-
A previous version used:
Which is fine for columns to the right of previously populated columns. Would anyone have any suggestions for any improvements?
Many thanks,
D€$
So, having written this question so far I’ve decided to break it down so we handle and complete only one column at a time now.
This has just taken around 100 seconds to execute. So far, so good. Now, unfortunately, the reasons for exclusion columns don’t run in the same order that the exclusions are processed so some of the formulae just look a bit clunky :-
Code:
Sub incorrectlength()
'8) "No/Incomplete Tel No/Tel No Length"
With Rows("1:1")
XCol8 = .Find(What:="incorrectlength", After:=[A1], LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column
End With
Range("DT2").FormulaR1C1 = _
"=IF(OR(RC[2]=""Yes"",RC[3]=""Yes"",RC[4]=""Yes"",RC[5]=""Yes"",RC[-3]=""Yes"",RC[-2]=""Yes"",RC[-1]=""Yes""),""No"" " & _
",IF(RC" & XCol8 & "=""Yes"",""Yes"",""No""))"
'If anything else = "Yes", "No", If(incorrectlength = "Yes",No/Incomplete Tel No/Tel No Length
Range("DT2").AutoFill Destination:=Range("DT2:DT" & EndRow), Type:=xlFillValues 'Retain current cell format
ActiveSheet.Calculate
Range(("DT2"), Range("DT" & EndRow)).Copy
Range("DT2").PasteSpecial Paste:=xlPasteValues
End Sub
A previous version used:
Code:
"=IF(COUNTIF(RC93:RC[-1],""Yes"")>0,""No""
Which is fine for columns to the right of previously populated columns. Would anyone have any suggestions for any improvements?
Many thanks,
D€$