Billdub417
New Member
- Joined
- Nov 5, 2019
- Messages
- 45
Hello,
I have used a macro to check whether numbers are included in a list, and if not, add these to the bottom of said list.
However, the code i am using is quite slow / basic and i think it could be simplified - glad of any assistance.
thanks in advance,
I have used a macro to check whether numbers are included in a list, and if not, add these to the bottom of said list.
However, the code i am using is quite slow / basic and i think it could be simplified - glad of any assistance.
thanks in advance,
VBA Code:
Sub UpdateList()
Sheets("Sheet2").Select
Range("H1").Select
ActiveCell.FormulaR1C1 = "=RC[-7]"
Selection.AutoFill Destination:=Range("H1:H20"), Type:=xlFillDefault
Sheets("Sheet1").Select
Range("A2:A25").Select
Selection.Copy
Sheets("Sheet2").Select
Range("H21").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Range("$H$1:$H$55").RemoveDuplicates Columns:=1, Header:=xlNo
Range("I1").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(IF(RC[-1]<>"""",VLOOKUP(RC[-1],Sheet1!R2C1:R25C3,2,FALSE),""""),""Enter Ref"")"
Range("I1").Select
Selection.AutoFill Destination:=Range("I1:I55"), Type:=xlFillDefault
Range("I1:I55").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("J1").Select
ActiveCell.FormulaR1C1 = _
"=IFNA(IF(RC[-2]<>"""",VLOOKUP(RC[-2],Sheet1!R2C1:R25C3,3,FALSE),""""),""Enter Ref"")"
Range("J1").Select
Selection.AutoFill Destination:=Range("J1:J55"), Type:=xlFillDefault
Range("J1:J55").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Range("A2:c55").Select
Selection.ClearContents
Sheets("Sheet2").Select
Range("H1:J1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Sheet1").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Columns("H:K").Select
Selection.ClearContents
Sheets("Sheet1").Select
Range("A1").Select
End Sub