Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Select a variable range | Excel Programming | |||
Use a Variable to select a range | Excel Discussion (Misc queries) | |||
select a variable range | Excel Programming | |||
Select a Range Through a Variable | Excel Programming | |||
Can I select a range based on the cell's contents? | Excel Programming |