newhousekk
New Member
- Joined
- Jan 26, 2011
- Messages
- 4
Hello,
I am trying to use a named range for a number of functions within an Excel worksheet. My first step is to clear subtotals and previous content from the area of the named range. I have been receiving the error directly below at the first line of code where I attempt to set the range. I have tried several different approaches and keep hitting a wall. I will also be wanting to sort and subtotal the named range in future code. I would appreciate any help.
Thanks
Karen
Run Time error 424 - Object Required
I am trying to use a named range for a number of functions within an Excel worksheet. My first step is to clear subtotals and previous content from the area of the named range. I have been receiving the error directly below at the first line of code where I attempt to set the range. I have tried several different approaches and keep hitting a wall. I will also be wanting to sort and subtotal the named range in future code. I would appreciate any help.
Thanks
Karen
Run Time error 424 - Object Required
Code:
Dim myrng As Range
'Step 1: Clear subtotals and clear previous content
Set myrng = (MF_Data_2011)
Worksheets("2011 MF Data").myrng.Select
Selection.RemoveSubtotal
myrng.ClearContents
Set myrng = (NFF_Data_2011)
Worksheets("2011 Frozen Data").myrng.Select
Selection.RemoveSubtotal
myrng.ClearContents
Set myrng = (MF_Kashi_2011)
Worksheets("2011 MF Kashi").myrng.Select
Selection.RemoveSubtotal
myrng.ClearContents