activecell

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301
Does anyone know how i can determine the activecell contents of a hidden sheet then i want to apply a if statement to it.
My idea is this if someone manages to unprotect this sheet and tampers with it i will have a number in that cell,then if cell <>123456 then the workbook will destroy itself.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Emily

Active Member
Joined
Aug 28, 2002
Messages
304
In the hidden sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(1, 1) <> 123456 Then
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
 

Emily

Active Member
Joined
Aug 28, 2002
Messages
304
I think you can assign a cell, say C1 in other sheet, = A1 of the hidden sheet. And use the code bellow to check the change of C1:

Private Sub Worksheet_Calculate()
If Cells(1, 3) <> 123456 Then
ThisWorkbook.Close SaveChanges:=False
End If
End Sub
 

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301

ADVERTISEMENT

Emily i appreciate your help but i dont think i have made myself very clear.
I want to be able to tell if the sheet has been changed because when i save it i will leave my mouse on say cell a1 which has the contents 123456 if the sheet has been accessed it is unlikely it would still be on a1.So with saying that i want a if statement on auto_open to determine if the sheet has been opened. (I have some code which deletes the active sheet without sending it to the recycle bin.
 

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301

ADVERTISEMENT

Can the position of the activecell be returned A1 ?
 

Dragracer

Board Regular
Joined
Jun 9, 2002
Messages
151
I think you would be better off capturing a event like the sheet change or activate to trigger your code. As Emily was suggesting.

If your VBA is passworded, your sheet protected and set to xlsheetveryhidden the only way to unhde is through VBA. If they go to all the work to crack that they would probably clean out your self destruct code.

Anyway back to your original question. First you need to have a sheet active to see which is the activecell. Try this it will work on hidden sheet.<pre>
Sub hidsh()
Worksheets("Sheet3").Activate
If ActiveCell.Address = "$A$1" Then
MsgBox "File is Good"
Else:
MsgBox "boom"
End If
End Sub</pre>
This message was edited by Dragracer on 2002-09-29 01:17
 

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301
thankyou dragracer that was excellent i just
changed $a$1 to 123456 works great
 

Forum statistics

Threads
1,143,925
Messages
5,721,562
Members
422,372
Latest member
RoyRodger

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
Top