Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Macro not running in Protect Sheet

Hi,

I have a macro, With the help of this macro, as soon as u write
anything in Column A it would automatically throws a Current Date in
Column G:


Dim LastRow, LastCol, CurRow, CurCol As Integer

Private Sub Worksheet_Change(ByVal Target As Range)
If LastCol = 1 Then
CurRow = ActiveCell.Row
CurCol = ActiveCell.Column
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column

'MsgBox Target

If Sheet1.Cells(LastRow, 7).Value = "" Then
Sheet1.Cells(LastRow, 7).Value = Date
Cells(LastRow, 4).Select
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
LastRow = ActiveCell.Row
LastCol = ActiveCell.Column
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column

End Sub


There are other formulas in the Excel Sheet. I had protected the sheet
to hide the formula. but as soon as i protected the sheet, my macro is
not working.


Can u help me how can i run the macro even after i protect the sheet.

Is there any way.

Thanks

Akash
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Macro not running in Protect Sheet

Hi Akash

You can not change any cell which is protected.

So you have to unprotect the cell before you can add the date.

Private Sub Worksheet_Change(ByVal Target As Range)
If LastCol = 1 Then
CurRow = ActiveCell.Row
CurCol = ActiveCell.Column
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column

'MsgBox Target
With Sheets(Sheet1)

If .Cells(LastRow, 7).Value = "" Then
.Unprotect
.Cells(LastRow, 7).Value = Date
.Cells(LastRow, 4).Select
.Protect
End If
End With
End If
End Sub

Regards,

Per

"Akash" skrev i en meddelelse
...
Hi,

I have a macro, With the help of this macro, as soon as u write
anything in Column A it would automatically throws a Current Date in
Column G:


Dim LastRow, LastCol, CurRow, CurCol As Integer

Private Sub Worksheet_Change(ByVal Target As Range)
If LastCol = 1 Then
CurRow = ActiveCell.Row
CurCol = ActiveCell.Column
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column

'MsgBox Target

If Sheet1.Cells(LastRow, 7).Value = "" Then
Sheet1.Cells(LastRow, 7).Value = Date
Cells(LastRow, 4).Select
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
LastRow = ActiveCell.Row
LastCol = ActiveCell.Column
'MsgBox ActiveCell.Row
'MsgBox ActiveCell.Column

End Sub


There are other formulas in the Excel Sheet. I had protected the sheet
to hide the formula. but as soon as i protected the sheet, my macro is
not working.


Can u help me how can i run the macro even after i protect the sheet.

Is there any way.

Thanks

Akash



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to allow auto filter after running password protect Roady Excel Discussion (Misc queries) 1 July 17th 08 06:34 PM
Macro not running in Protect Sheet Akash Excel Programming 0 January 16th 08 12:39 PM
Protect sheet in macro traima Excel Worksheet Functions 3 March 9th 07 06:05 PM
Password Protect Running of Macro John Excel Programming 8 September 27th 05 02:49 AM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 03:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"