floridagunner
Board Regular
- Joined
- Jul 20, 2007
- Messages
- 60
Hello,
I'm trying to define two ranges using the "SET" keyword function in VBA, but my code does not seem to be working. What I want to do is to be able to activate the macro from any worksheet or cell in the workbook and the macro should take me to the defined range. However everytime I run the macro from another sheet I get the following error:
""Run-time error '1004': Application-defined or object defined error"
Also the macro only seems to work properly when I activate it from cell A1 of the "SAP Refined Data" worksheet.
My code is as follows:
Can anyone advise me on where I'm going wrong?
Thanks
I'm trying to define two ranges using the "SET" keyword function in VBA, but my code does not seem to be working. What I want to do is to be able to activate the macro from any worksheet or cell in the workbook and the macro should take me to the defined range. However everytime I run the macro from another sheet I get the following error:
""Run-time error '1004': Application-defined or object defined error"
Also the macro only seems to work properly when I activate it from cell A1 of the "SAP Refined Data" worksheet.
My code is as follows:
Code:
Sub ConversionRange()
Set myRange = Sheets("SAP Refined Data").Range("1:1")
Set cRange = myRange.Find(What:="Cost Element").Offset(1, 0).Range(Selection, Selection.End(xlDown))
cRange.Select
End Sub
Can anyone advise me on where I'm going wrong?
Thanks