PDA

View Full Version : About referring to cells



wpanssi
11-06-2008, 03:29 AM
I have understood that
cells(x,y)
and
activesheet.cells(x,y)
means the same.

If I want to refer to thisworkbook.activesheet.cells(x,y), is there a shorter way to do it? Is it possible to make cells always refer to thisworkbook.activesheet.cells?

Thanks!

Bob Phillips
11-06-2008, 03:40 AM
With ThisWorkbook.Activesheet

.Cells(x,y)
.etc

End With

wpanssi
11-06-2008, 04:21 AM
Ok. That seems to work. Thanks!

mdmackillop
11-06-2008, 11:28 AM
You can also create a variable for the sheet, and use that throughout your code.

Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
ws.Cells(x, y).etc.