View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
DownThePaint DownThePaint is offline
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?