Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Need help adjusting selection ranges

Hey all. I am sure you all have seen the basic code listed below. What I need
to know is how to change the "Selection.end(xldown)" part to a variable
place, like 100 columns to the right?


Range(Selection, Selection.End(xlDown)).Select

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need help adjusting selection ranges

Do you mean search down 100 columns to the right, or search down then 100
columns to the right? If the later

Range(Selection, Selection.End(xlDown)).Offset(0,100).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"havocdragon" wrote in message
...
Hey all. I am sure you all have seen the basic code listed below. What I

need
to know is how to change the "Selection.end(xldown)" part to a variable
place, like 100 columns to the right?


Range(Selection, Selection.End(xlDown)).Select



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Need help adjusting selection ranges

I mean instead of selection.end(xldown) is there another method of selecting
without a variable. For instance say I want to select 100 cells down from the
current cell in A1, however the current cell will not always be A1, it can be
variable between columns. How would I change the selection so it selected 100
cells down from the current, or even better, how could I use a created
variable that says how many cells to go down apply?

"Bob Phillips" wrote:

Do you mean search down 100 columns to the right, or search down then 100
columns to the right? If the later

Range(Selection, Selection.End(xlDown)).Offset(0,100).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"havocdragon" wrote in message
...
Hey all. I am sure you all have seen the basic code listed below. What I

need
to know is how to change the "Selection.end(xldown)" part to a variable
place, like 100 columns to the right?


Range(Selection, Selection.End(xlDown)).Select




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need help adjusting selection ranges

Take a look at .resize:

dim myCell as range
dim NumOfRows as long
dim numofcols as long
dim myRng as range

set mycell = activesheet.range("x99")
numofrows = 100
set myrng = mycell.resize(numofrows)
'now myrng is 100 rows

numofcols = 18
set myrng = mycell.resize(numofrows,numofcols)
'now myrng is 100 rows by 18 columns.

If you don't resize one of the dimensions, it doesn't change:

set myrng = range("a1:C3")
set myrng = myrng.resize(100) '100 rows by 3 columns

set myrng = range("a1:C3")
set myrng = myrng.resize(,31) '3 rows by 31 columns.

When you're looking at .resize, you may want to look at .offset. You can "move"
right/left/up/down with that.


havocdragon wrote:

I mean instead of selection.end(xldown) is there another method of selecting
without a variable. For instance say I want to select 100 cells down from the
current cell in A1, however the current cell will not always be A1, it can be
variable between columns. How would I change the selection so it selected 100
cells down from the current, or even better, how could I use a created
variable that says how many cells to go down apply?

"Bob Phillips" wrote:

Do you mean search down 100 columns to the right, or search down then 100
columns to the right? If the later

Range(Selection, Selection.End(xlDown)).Offset(0,100).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"havocdragon" wrote in message
...
Hey all. I am sure you all have seen the basic code listed below. What I

need
to know is how to change the "Selection.end(xldown)" part to a variable
place, like 100 columns to the right?


Range(Selection, Selection.End(xlDown)).Select





--

Dave Peterson
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
adjusting sums ericaamousseau Excel Discussion (Misc queries) 6 January 27th 09 11:17 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Adjusting Referances Lanza52 Excel Worksheet Functions 0 August 21st 06 12:49 AM
Need help adjusting my code: HouseofRahl[_2_] Excel Programming 1 July 12th 05 10:53 PM
Sort Macro: Utilizing ComboBox Selection for Key1 through 3 Ranges buddhapenguin Excel Discussion (Misc queries) 0 May 13th 05 03:01 PM


All times are GMT +1. The time now is 09:49 AM.

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"