ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Range Variables... (https://www.excelbanter.com/excel-programming/383287-vba-range-variables.html)

MarkHear1

VBA Range Variables...
 
I have tried written the following code, however it's incorrect and I
can't seem to work out how to correct it. Could anybody offer any help
please?

Sub test()

Range("A1").Select
Dim Start As Range
Set Start = ActiveCell


Range("a5").Select
Dim Final As Range
Set Final = ActiveCell

Range (Start:Final).Select

End Sub

Many Thanks
Mark


[email protected]

VBA Range Variables...
 
Hi
you need a comma not a colon
Range(Start, Final).Select

the colon goes in the text address for the range
Range("A1:A5").Select

or even
Range(Start.Address & ":" & Final.Address).Select

regards
Paul

On Feb 15, 11:39 am, "MarkHear1" wrote:
I have tried written the following code, however it's incorrect and I
can't seem to work out how to correct it. Could anybody offer any help
please?

Sub test()

Range("A1").Select
Dim Start As Range
Set Start = ActiveCell

Range("a5").Select
Dim Final As Range
Set Final = ActiveCell

Range (Start:Final).Select

End Sub

Many Thanks
Mark




MarkHear1

VBA Range Variables...
 
On 15 Feb, 11:48, wrote:
Hi
you need a comma not a colon
Range(Start, Final).Select

the colon goes in the text address for the range
Range("A1:A5").Select

or even
Range(Start.Address & ":" & Final.Address).Select

regards
Paul

On Feb 15, 11:39 am, "MarkHear1" wrote:



I have tried written the following code, however it's incorrect and I
can't seem to work out how to correct it. Could anybody offer any help
please?


Sub test()


Range("A1").Select
Dim Start As Range
Set Start = ActiveCell


Range("a5").Select
Dim Final As Range
Set Final = ActiveCell


Range (Start:Final).Select


End Sub


Many Thanks
Mark- Hide quoted text -


- Show quoted text -


Thank you for your help Paul!! :-)



All times are GMT +1. The time now is 09:53 PM.

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