Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default selecting multiple rows within a Macro

Ronald,

Looks like you had several typos in this:

ActiveWorksheet should be ActiveSheet,
UsedRange probably isn't a good choice for a variable name. (caused me an
error)

UsedRange.Rows and UsedRange.Columns are objects. Think you want
UsedRange.Rows.count and UsedRange.Columns.count

You have your math backwards
Should be UsedRange.Columns.count - UsedRange.Column + 1

Anyway, here is a possible revision:

Sub Tester1()
Dim uRange As Range, LastColumn As Long, LastRow As Long
Set uRange = ActiveSheet.UsedRange
LastColumn = uRange.Columns.Count - uRange.Column + 1
LastRow = uRange.Rows.Count - uRange.Row + 1
ActiveSheet.Range(ActiveCell, Cells(LastRow, LastColumn)).Select
End Sub

This one is a little less typing.

Sub Tester2()
Dim uRange As Range
Set uRange = ActiveSheet.UsedRange
ActiveSheet.Range(ActiveCell, uRange(uRange.Count)).Select
End Sub

--
Regards,
Tom Ogilvy


Ronald Dodge wrote in message
...
Maybe you could try something like:

Dim UsedRange as Range, LastColumn as Long, LastRow as Long
Set UsedRange = ActiveWorksheet.UsedRange
LastColumn = UsedRange.Column + UsedRange.Columns - 1
LastRow = UsedRange.Row + UsedRange.Rows - 1
ActiveWorksheet.Range(ActiveCell,Cells(LastRow,Las tColumn)).Select

This is what I found in the help file under the Worksheet Object list of
Properties.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Eric Dreshfield" wrote in message
...
How can I write the code to select multiple rows in a
Macro ? I want the macro to mimic the following
keystrokes:

Ctrl-Shift-End

to select a range of cells from where the cursor currently
resides to the end of where data exists.

I can't seem to figure out how to accomplish that.

Thanks !!





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting multiple objects with macro Memphus01 Excel Discussion (Misc queries) 3 December 2nd 08 07:30 PM
How can I stop Excell selecting multiple rows? Chris L 99 Excel Discussion (Misc queries) 5 October 15th 08 06:50 PM
Selecting multiple rows Soheyl Excel Discussion (Misc queries) 1 June 12th 07 01:41 AM
selecting multiple rows within a Macro Eric Dreshfield Excel Programming 0 August 29th 03 09:14 PM
selecting multiple rows within a Macro Jean-Paul Viel Excel Programming 0 August 29th 03 09:04 PM


All times are GMT +1. The time now is 03:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"