Phil Payne
Board Regular
- Joined
- May 17, 2013
- Messages
- 131
- Office Version
- 365
- Platform
- Windows
Hello all,
I am using a combo box on sheet1 with a defined 'listfillrange' that refers to a column in a range of data on sheet2.
Everything works as it should until I either sort or filter the data on sheet2 whereupon I get - "Run-Time error '1004': Select method of Range class failed" on line 3 of code below.
Sheet1 code
Can anyone tell me what can do to prevent this run-time error occurring?
Thanks.
I am using a combo box on sheet1 with a defined 'listfillrange' that refers to a column in a range of data on sheet2.
Everything works as it should until I either sort or filter the data on sheet2 whereupon I get - "Run-Time error '1004': Select method of Range class failed" on line 3 of code below.
Sheet1 code
Code:
Option Explicit
Private Sub ComboBox1_Change()
Worksheets("Sheet1").Range("C8:C54").Select
Selection.Interior.ColorIndex = xlNone
Worksheets("Sheet1").Range("G8:G54").ClearContents
Application.ScreenUpdating = False
Sheets("Sheet1").Activate
ActiveSheet.Range("D8").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R141C162,13)"
ActiveSheet.Range("D9").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R141C162,16)"
ActiveSheet.Range("D10").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R141C162,19)"
'etc
End Sub
Can anyone tell me what can do to prevent this run-time error occurring?
Thanks.