Good afternoon I'm trying to improve some code:
I 'suspect' the After:=ActiveCell may have something to do with my initial stumble. I think the rest of the code shouldn't be a huge problem - it's just Step #1 that has tripped me up.
Many thanks,
D€$
Code:
Code = "Code End" ' Final column of codes in "MyCodeframe" workbook. Need to add word values to the subsequent columns.
Q1Array = Array("Q1a", "Q1b", "Q1c", "Q25")
For Each Q1 In Q1Array
'********** From here:
Workbooks(MyCodeframe).Activate
Sheets(Q1).Activate
'use cells.rows.count rather than a hard row count value
EndRow = Cells(Cells.Rows.Count, 1).End(xlUp).Row
Rows("1:1").Select
Selection.Find(What:=Code, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
CodeColumn = ActiveCell.Column + 1
For x = 0 To 7 '8 columns
Cells(2, CodeColumn + x).Select
ActiveCell.FormulaR1C1 = _
"=INDEX('[" & CodeFrameMaster & "]" & Q1 & "'!C3,MATCH(RC[-8],'[" & CodeFrameMaster & "]" & Q1 & "'!C4,0),1)"
Next x
For x = 0 To 7 '8 columns
.Cells(2, CodeColumn + x).FormulaR1C1 = _
"=INDEX('[" & CodeFrameMaster & "]" & Q1 & "'!C3,MATCH(RC" & CodeColumn + x - 8 & ",'[" & CodeFrameMaster & "]" & Q1 & "'!C4,0),1)"
Next x
Range(Cells(2, CodeColumn), Cells(2, CodeColumn + x - 1)).AutoFill Destination:=Range(Cells(2, CodeColumn), (Cells(EndRow, CodeColumn + x - 1)))
ActiveSheet.Calculate
Range(Cells(2, CodeColumn), (Cells(EndRow, CodeColumn + x - 1))).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
'********
With Workbooks(MyCodeframe).Sheets(Q1)
EndRow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row
With .Rows("1:1")
CodeColumn = .Find(What:=Code, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Column + 1
End With
I 'suspect' the After:=ActiveCell may have something to do with my initial stumble. I think the rest of the code shouldn't be a huge problem - it's just Step #1 that has tripped me up.
Many thanks,
D€$