ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy question (https://www.excelbanter.com/excel-programming/354988-easy-question.html)

londono001

Easy question
 
Hi there,
Can you tell when one has to reference a cell by the spreadsheet name it
belongs to and when it is not required?

Calling this sub from Sheet1
Sub Button1
Worksheets("Sheet2").Activate
Range("A3").Select
End
Return Range("A3") from Sheet1

#1: Is the solution to use Worksheets("Sheet2").Range("A3")?
#2: Is the solution to use use named range (unique for the workbook) for
Worksheets("Sheet2").Range("A3") and then reference this name directly

Thanks
Ben

Bob Phillips[_6_]

Easy question
 
You have to reference the sheet as well when the sheet that you want is not
the active sheet, or that you don't know it is the active sheet. It is
probably good practice to always use a sheet reference.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"londono001" wrote in message
...
Hi there,
Can you tell when one has to reference a cell by the spreadsheet name it
belongs to and when it is not required?

Calling this sub from Sheet1
Sub Button1
Worksheets("Sheet2").Activate
Range("A3").Select
End
Return Range("A3") from Sheet1

#1: Is the solution to use Worksheets("Sheet2").Range("A3")?
#2: Is the solution to use use named range (unique for the workbook) for
Worksheets("Sheet2").Range("A3") and then reference this name directly

Thanks
Ben





All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com