Solved

Select variable range of cells in Excel using VB

Posted on 2004-09-19
6
1,594 Views
Last Modified: 2012-06-22
I want to select a variable range of cells in an Excel worksheet. To cell is A1, bottom cell can be found by using SHIFT+CTRL+DOWN ARROW.

If I record this as a macro it records the absolute or actual cell identified when the macro is run, i.e. it can not be run as a general macro.

Is there a VB equivalent to SHIFT+CTRL+DOWN ARROW?

I'm using Office 2000
0
Comment
Question by:irh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12098875
try

vbkeyshift + vbkeycontrol + vbkeydown

or

vbkeyshift & vbkeycontrol & vbkeydown

mlmcc
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12100308
There is a special syntax to do this.

xlWB.ActiveSheet.Range("A1").Select  ' Begin select range
xlWB.ActiveSheet.Range(Selection, Selection.End(xlDown)).Select  ' Select till it spans
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 12100312
Correct syntax

xlWB.ActiveSheet.Range("A1").Select
xlWB.ActiveSheet.Range(xlWB.ActiveSheet.Range("A1"), xlWB.ActiveSheet.Range("A1").End(-4121)).Select
0
 
LVL 13

Accepted Solution

by:
bochgoch earned 125 total points
ID: 12103257
Use this....

Set xlWB = xlApp.Workbooks.Open(useworkbook) ' useworkbook = existing workbook
Dim rng1 As Range
xlWB.Activate
Set rng1 = xlWB.Worksheets(1).UsedRange
0
 

Author Comment

by:irh
ID: 12592616
bochgoch's answer has worked on one of my sheets - but not on 2 others - not sure why at the moment!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question