ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to select a defined range (https://www.excelbanter.com/excel-programming/335192-vba-select-defined-range.html)

Shawn

VBA to select a defined range
 
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

Don Guillett[_4_]

VBA to select a defined range
 
Try this without anything else to goto a range/cell named bill
However, it is rarely necessary to select to do something. More info?

Sub gothere()
Application.Goto "bill"
End Sub


--
Don Guillett
SalesAid Software

"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




George Nicholson[_2_]

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




M. Authement

VBA to select a defined range
 
I think you need to Set the DataSD object.

"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




Bob Phillips[_7_]

VBA to select a defined range
 
Neither DataSD nor MMR have been set to any objects.

In addition the syntax is

Set DataSD = Worksheets("Sheet1")
Set MMR = DataSD.Range("A1")

or so

--
HTH

Bob Phillips

"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




Shawn

VBA to select a defined range
 
This link also helped me:

http://groups-beta.google.com/group/...9892a2449a7ced


--
Thanks
Shawn


"Shawn" wrote:

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



All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com