View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike McCollister Mike McCollister is offline
external usenet poster
 
Posts: 6
Default How Do I Create a Range in Excel VBA?

OK. This is strange. I am trying to add this to an existing function. When I
put this in:

Set r3 = ThisWorkbook.Worksheets("Sheet1").range(Cells(15, 16),
Cells(110, 120))

"Range" is not capitalized. If I create a new spreadsheet then it works OK.
Any idea how to get this to work with the existing spreadsheet?

Thanks,

Mike


"Gary''s Student" wrote in message
...
Sub mike()
Set r = Range(Cells(5, 6), Cells(10, 20))
MsgBox (r.Address)
r.Select
End Sub

--
Gary''s Student
gsnu200710


"Mike McCollister" wrote:

I am trying to figure this one out. I want to create a range on a sheet.
I
know the row and column numbers for the upper left and the bottom right.
I've
tried the following without any luck but I think that I am close:

-- begin code --
sheetOfInterest = "Sheet1"
topRow = 5
topColumn = 6
bottomRow = 10
bottomColumn = 20

rem THIS DOES NOT WORK
newRange = ThisWorkbook.Worksheets(sheetOfInterest).Range(Cel ls(topRow,
topColumn), Cells(bottomRow, BottomColumn))
-- end code --

Once I get this working then I can get the rest done :).

Thanks,

Mike McCollister