ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range question (https://www.excelbanter.com/excel-programming/342281-range-question.html)

Patrick Simonds

Range question
 
In the code below how can I make the range in the following line point to
the Worksheet named Sunday (cell B1000)?

If Range("B1000").Value = "xxx" Then


Private Sub Workbook_BeforeClose(Cancel As Boolean)


If Range("B1000").Value = "xxx" Then

Range("B1").Select
ThisWorkbook.Close False

Else: Range("B1").Select

End If
Range("B1").Select
Application.EnableEvents = True

End Sub



JS2004R6

Range question
 
Hi Patrick,

You can refer to that worksheet using the below line:

Thisworkbook.Worksheets("Sunday").Range("B1000").V alue

Hope that helps.

Regards,
James

"Patrick Simonds" wrote:

In the code below how can I make the range in the following line point to
the Worksheet named Sunday (cell B1000)?

If Range("B1000").Value = "xxx" Then


Private Sub Workbook_BeforeClose(Cancel As Boolean)


If Range("B1000").Value = "xxx" Then

Range("B1").Select
ThisWorkbook.Close False

Else: Range("B1").Select

End If
Range("B1").Select
Application.EnableEvents = True

End Sub





All times are GMT +1. The time now is 09:06 AM.

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