View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sebastien Sebastien is offline
external usenet poster
 
Posts: 22
Default absolute relative reference

Good day,

Situation:

I am having a macro in "sheet_1" that is doing a whole bunch of operations.
The macro uses a combination of absolute references such as:

Cells(1, "C") = ...

as well as relative references such as:

Range("B1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 1).Select

My problem:

When I need the macro to execute an operation in the next sheet of my
workbook "sheet_2", I write something as simple as:

Sheets("sheet_2").Select
Range("A3:A200").Select

but I have an error message at the second line "Range("A3:A200").Select". I
have never seen this kind of error before. My second line must be written as

Sheets("sheet_2").Range("A2:K2").Select

Usually, When I select a sheet, I do not need to "re-select" it in each line
of the macro, but for this one, I am obliged to do so and it gets quite
annoying.

I think there is a problem of reference (absolute vs relative). Or maybe my
macro is dedicated to sheet_1 only? If this is the case, how do I make it
valid for the whole workbook? In any case, please help!

--
Thanks
Sebastien