View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
George Nicholson[_2_] George Nicholson[_2_] is offline
external usenet poster
 
Posts: 170
Default VBA to select a defined range

In your code you have declared DataSD as a Worksheet but you haven't set it
to anything before you use it. This causes an error.

Set DataSD = Worksheets("SheetNameContainingMMRange") 'This line is
missing
Set MMR = DataSD.Range("MMRrange") 'Needs
to know what DataSD is or you'll get an error

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"Shawn" wrote in message
...
Thanks in advance to all who help on this site.

I have the below code:


Public Sub MMR()

' Keyboard Shortcut: Ctrl+x

Dim DataSD As Worksheet
Dim MMR As Range
Set MMR = DataSD.Range("MMRrange")

MMR.Select

End Sub

When I Set MMR to = DataSD.Range("MMRrange") the MMRrange refers to a
defined range of cells on the DataSD worksheet. However, I have something
wrong for when I run this program this line gives an error?




--
Thanks
Shawn