ThisSheet or ThisWorksheet

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
687
Office Version
  1. 2007
Platform
  1. Windows
Hi,
how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
to ThisSheet or ThisWorksheet?

Tia.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
maurizio.rota said:
Hi,
how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
to ThisSheet or ThisWorksheet?

Tia.

The event refers to a change on the active worksheet anyway, so there's no need to qualify references to ranges etc. If you want, you can use the Me keyword within a worksheet's module to refer to the worksheet.
 
Upvote 0
Mudface said:
maurizio.rota said:
Hi,
how there is: ActiveWorkbook AND ThisWorkbook, is there ThisSheet or ThisWorksheet (from ActiveSheet)?

How can I refer a "Private Sub Worksheet_Change(ByVal Target As Range)"
to ThisSheet or ThisWorksheet?

Tia.

The event refers to a change on the active worksheet anyway, so there's no need to qualify references to ranges etc. If you want, you can use the Me keyword within a worksheet's module to refer to the worksheet.

Hi Mudface,
this all my code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Dat7 As Byte, DatB_C As Byte, DatB As Byte, DatC As Byte, DifOK As Byte
Dim ImpOk As Long
    Dat7 = Application.WorksheetFunction.CountA(ActiveSheet.Range("B5:B13"))
    ImpOk = Abs(ActiveSheet.Range("B2"))
    DatB_C = Application.WorksheetFunction.CountA(ActiveSheet.Range("B15:C24"))
    DatB = Application.WorksheetFunction.CountA(ActiveSheet.Range("B15:B24"))
    DatC = Application.WorksheetFunction.CountA(ActiveSheet.Range("C15:C24"))
    If Dat7 >= 7 And DatB_C >= 2 And DatB = DatC And ImpOk = 0 Then Cells(65536, 2).End(xlUp).Offset(1, 0).Select
End Sub

and if I active an other sheet with click-mouse while a cell of ActiveSheet is active (is working: I don't push enter key) I get error.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top