Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default ctrl-end in VBA

I want to select a range from C3 to "last cell" in many different workbooks.
I know have to do this manually with SHIFT-CTRL-END but is there a simple
way to do this with VBÀ?

Torstein Johnsen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default ctrl-end in VBA

try

Sub sce()
ActiveSheet.UsedRange.Select
End Sub
--
Don Guillett
SalesAid Software

"Torstein S. Johnsen" wrote in message
...
I want to select a range from C3 to "last cell" in many different

workbooks.
I know have to do this manually with SHIFT-CTRL-END but is there a simple
way to do this with VBÀ?

Torstein Johnsen




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ctrl-end in VBA

Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default ctrl-end in VBA

Torstein;

Use This

Range("C3").Select
Range(Selection, ActiveCell.SpecialCells
(xlLastCell)).Select

Thanks,

Greg
-----Original Message-----
I want to select a range from C3 to "last cell" in many

different workbooks.
I know have to do this manually with SHIFT-CTRL-END but

is there a simple
way to do this with VBÀ?

Torstein Johnsen


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default ctrl-end in VBA

Torstein

The last cell may not be where you think it is.

Excel has a habit of including cells that once held data but were cleared.

Either of the two codes posted could give you an incorrect "last cell"
selection.

To reset the used range before running the code, see Debra Dalgleish's site

http://www.contextures.on.ca/xlfaqApp.html#Unused

Alternative..........

Add this UDF to your workbook........

Function RangeToUse(anySheet As Worksheet) As Range
'Bob Flanagan creation slightly modified by Gord Dibben
'this function returns the range from Activecell to cell which is the
'intersection of the last row with an entry and the last column with an entry.
'used with UsedRangePick macro.....REAL USED RANGE!!
Dim i As Integer, c As Integer, R As Integer

With anySheet.UsedRange
i = .Cells(.Cells.Count).Column + 1
For c = i To 1 Step -1
If Application.CountA(anySheet.Columns(c)) 0 _
Then Exit For
Next
i = .Cells(.Cells.Count).Row + 1
For R = i To 1 Step -1
If Application.CountA(anySheet.Rows(R)) 0 Then _
Exit For
Next
End With

With anySheet
Set RangeToUse = .Range(ActiveCell, .Cells(R, c))
'note activecell could be hard-coded to a specific cell reference
End With
End Function

Then run this macro.

Sub UsedRangePick()
Dim tempRange As Range
Set tempRange = RangeToUse(ActiveSheet)
tempRange.Select
End Sub

Gord Dibben Excel MVP

On Tue, 4 May 2004 14:49:53 +0200, "Torstein S. Johnsen"
wrote:

I want to select a range from C3 to "last cell" in many different workbooks.
I know have to do this manually with SHIFT-CTRL-END but is there a simple
way to do this with VBÀ?

Torstein Johnsen




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
Is there a difference between CTRL+D and CTRL+" (quotation marks) AKMMS Excel Discussion (Misc queries) 2 March 22nd 10 07:43 PM
How to make Ctrl-C, ctrl-V work in Office 2007 hj Excel Discussion (Misc queries) 1 June 23rd 09 01:09 PM
Excel 2007: Ctrl+PgUp or Ctrl+PgDn with Protected Sheets DrDave Excel Discussion (Misc queries) 1 July 28th 08 04:12 AM
use CTRL key inside a macro IE CTRL + ; Date Less Excel Worksheet Functions 1 April 14th 08 11:58 PM
How to forbid ctrl+c and ctrl+X in sheet? GR Setting up and Configuration of Excel 2 December 24th 06 03:39 AM


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

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

About Us

"It's about Microsoft Excel"