Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default select the range with the cell's position is a variable.

can anyone tell me how to select a range which will keep changing? for
eg:
Sub select_range()
Dim abc As Range
Dim a As Integer
Dim b As Integer

a = 2 + 2
b = 2
abc = Range("ab")
abc.Select

End Sub

How to modify the code if i wish to make the a, b as a variable?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default select the range with the cell's position is a variable.

Hi youu917;

You can create a function and pass the values to it something like this:

Sub ExampleOfCallingMyFunction
varFirstRow = 1
varMyFirstColumn = 1
varMyLastRow = 10
varMyLastColumn = 2
GoSelectMyRange varFirstRow, varMyFirstColumn, varMyLastRow,
varMyLastColumn
End Sub

Function GoSelectMyRange (varFirstRow, varMyFirstColumn, varMyLastRow,
varMyLastColumn)
Range(Cells(varFirstRow,varMyFirstColumn), Cells(varMyLastRow,
varMyLastColumn)).Select
End Function

I Hope This Helps

" wrote:

can anyone tell me how to select a range which will keep changing? for
eg:
Sub select_range()
Dim abc As Range
Dim a As Integer
Dim b As Integer

a = 2 + 2
b = 2
abc = Range("ab")
abc.Select

End Sub

How to modify the code if i wish to make the a, b as a variable?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default select the range with the cell's position is a variable.

On Mar 14, 10:29*am, DownThePaint
wrote:
Hi youu917;

You can create a function and pass the values to it something like this:

Sub ExampleOfCallingMyFunction
* * *varFirstRow = 1
* * *varMyFirstColumn = 1
* * *varMyLastRow = 10
* * *varMyLastColumn = 2
* * *GoSelectMyRange varFirstRow, varMyFirstColumn, varMyLastRow,
varMyLastColumn
End Sub

Function *GoSelectMyRange (varFirstRow, varMyFirstColumn, varMyLastRow,
varMyLastColumn)
* * *Range(Cells(varFirstRow,varMyFirstColumn), Cells(varMyLastRow,
varMyLastColumn)).Select
End Function

I Hope This Helps



" wrote:
can anyone tell me how to select a range which will keep changing? for
eg:
Sub select_range()
Dim abc As Range
Dim a As Integer
Dim b As Integer


a = 2 + 2
b = 2
abc = Range("ab")
abc.Select


End Sub


How to modify the code if i wish to make the a, b as a variable?- Hide quoted text -


- Show quoted text -


Thank you very much
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
Select a variable range Eduardo Excel Programming 7 August 8th 07 01:46 PM
Use a Variable to select a range Connie Excel Discussion (Misc queries) 3 October 19th 06 05:48 PM
select a variable range evil baby[_15_] Excel Programming 4 March 8th 06 08:38 PM
Select a Range Through a Variable GoFigure[_9_] Excel Programming 3 December 6th 05 01:02 PM
Can I select a range based on the cell's contents? [email protected] Excel Programming 1 July 29th 05 11:08 AM


All times are GMT +1. The time now is 03:21 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"