View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
zuhair zuhair is offline
external usenet poster
 
Posts: 1
Default Unprotect Sheet Password in Macros

Sir,
I have a web site showing stock prices. By marking the rows and linking to
excel comand, sheet1 is linked and the data changing in the web is reflected
in sheet1. the problem is that in Worksheet_Change sub is not getting
activated although if I key in a number tha event is happening. any help.

code bellow

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

k = 1
Application.EnableEvents = False
SheetName = Worksheets("Sheet1").Cells(Target.Row, 2)

Do While Worksheets("Sheet1").Cells(Target.Row, k) < ""
Worksheets(SheetName).Cells(SheetsLastRow(Target.R ow), k) =
Worksheets("Sheet1").Cells(Target.Row, k)
k = k + 1
Loop

Worksheets(SheetName).Cells(SheetsLastRow(Target.R ow), k) = Time

If Target.Column = 3 Then
Call CheckThePrice(Target.Row)

End If

SheetsLastRow(Target.Row) = SheetsLastRow(Target.Row) + 1

Application.EnableEvents = True

End Sub


this code does what is suppose to do if manualy we chang the cell value then
hit enter. but not when the value is changed by link to the web site.

please email me.

thank you.


"sebastienm" wrote:

To unprotect a worksheet, assuming the book is already open:
Dim Wsh as worksheet
set wsh= activeworkbook.Worksheets(1) 'Eg: for 1 sheet of active book

wsh.unprotect "your_password"
'... do what you have to do here
'then reprotect with wsh.protect .....

(If you meant to unprotect a protected vba project, not the sheet, then it
is not possible through code)

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Theresa" wrote:

Hi:

I have an Excel file that has been used as a template to create 800+ files
that has the protection worksheet applied. I now what to add more formulas
to this file and want to use a macro to do it. How can I enter the unprotect
password automaticcaly as part of the macro and then protect the sheet again
before saving and closing?

Thanks