Setting a range using VBA

  • Thread starter Thread starter elswen
  • Start date Start date
E

elswen

How can I goto A2 then emulate the keystrokes [Control]
[Shift][End] then [Shift][Home] tocapture column A for
the height of the data using VBA?
Thanks
 
try

Sub selectit()
x = ActiveSheet.UsedRange.Rows.Count
Range(Cells(2, 1), Cells(x, 1)).Select
End Sub
 
I suggest this code if the data is continuous (no empty
cells)
Dim rng As Range
Set rng = Range(Range("A2"),Range("A2").End(xlDown))

or if not continuous
Dim rng As Range
Set rng = Range(Range("A2"),Range("A65536").End(xlUp))

Kevin Beckham
-----Original Message-----
try

Sub selectit()
x = ActiveSheet.UsedRange.Rows.Count
Range(Cells(2, 1), Cells(x, 1)).Select
End Sub
--
Don Guillett
SalesAid Software
(e-mail address removed)
How can I goto A2 then emulate the keystrokes [Control]
[Shift][End] then [Shift][Home] tocapture column A for
the height of the data using VBA?
Thanks


.
 
Kevin,
Perhaps a re-reading of OP's request would be helpful for you.

--
Don Guillett
SalesAid Software
(e-mail address removed)
Kevin Beckham said:
I suggest this code if the data is continuous (no empty
cells)
Dim rng As Range
Set rng = Range(Range("A2"),Range("A2").End(xlDown))

or if not continuous
Dim rng As Range
Set rng = Range(Range("A2"),Range("A65536").End(xlUp))

Kevin Beckham
-----Original Message-----
try

Sub selectit()
x = ActiveSheet.UsedRange.Rows.Count
Range(Cells(2, 1), Cells(x, 1)).Select
End Sub
--
Don Guillett
SalesAid Software
(e-mail address removed)
How can I goto A2 then emulate the keystrokes [Control]
[Shift][End] then [Shift][Home] tocapture column A for
the height of the data using VBA?
Thanks


.
 
Don,
You're right, it's just that I never consider empty
formatted cells to be "useful" .

Kevin
-----Original Message-----
Kevin,
Perhaps a re-reading of OP's request would be helpful for you.

--
Don Guillett
SalesAid Software
(e-mail address removed)
I suggest this code if the data is continuous (no empty
cells)
Dim rng As Range
Set rng = Range(Range("A2"),Range("A2").End(xlDown))

or if not continuous
Dim rng As Range
Set rng = Range(Range("A2"),Range("A65536").End(xlUp))

Kevin Beckham
-----Original Message-----
try

Sub selectit()
x = ActiveSheet.UsedRange.Rows.Count
Range(Cells(2, 1), Cells(x, 1)).Select
End Sub
--
Don Guillett
SalesAid Software
(e-mail address removed)
How can I goto A2 then emulate the keystrokes [Control]
[Shift][End] then [Shift][Home] tocapture column A for
the height of the data using VBA?
Thanks


.


.
 
Back
Top