Excel - Macro not running in Protect Sheet
Asked By Akash
17-Jan-08 06:37 AM
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
Sheets
(1)
Excel
(1)
ActiveCell.Column
(1)
Macro
(1)
Sheet1.Cells
(1)
AkashYou
(1)
LastCol
(1)
CurCol
(1)
Per Jessen replied...
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

Outils pour optimiser macro? Excel Bonjour: Je souhaiterais savoir s'il existe des outils et ou techniques pour diagnostiquer et / ou optimiser et / ou nettoyer le code d'une macro afin d'augmenter la rapidit = E9 de traitement ou les points de ralentissement. Remerciements et sinc = E8res. Christophe Excel - French Discussions WorksheetFunction (1) PageSetup (1) Worksheets (1) Scenarios (1) Interior (1) Borders (1) Sheets (1) Error (1) Bonjour Maud et merci. Est-ce que tu peux m'aider = E0 identifier les elements de la macro ci- dessous = E0 modifier pour acc = E9l = E9rer la vitesse de traitement? Beaucoup de ces lignes ont = E9t = E9 r = E9alis = E9es avec l'enregistreur de Macro ce qui = ne doit pas participer = E0 la fluidit = E9 de la macro. Remerciements et sinc = E8res salutations, Christophe Sub ShowtimeCompanyScheduler() If MsgBox(Prompt: = 3D"Are you really
End without Next Error Excel Check boxes to select what combination of sheets is printed. I am getting an End without Next Error. Help! Private Sub PrintSelected_Click() Application.Dialogs(xlDialogPrint).Show If CheckBox1 = True Then Sheets("ClientData").PrintOut If CheckBox2 = True Then Sheets("W1").PrintOut If CheckBox3 = True Then Sheets("Fee").PrintOut If CheckBox4 = True Then Sheets("Data").PrintOut If CheckBox5 = True Then Sheets("B1").PrintOut If CheckBox6 = True Then Sheets("B2").PrintOut If CheckBox7 = True Then Sheets("B3").PrintOut If CheckBox8 = True Then Sheets("B4
Extraction_données_suivant_sélection_dans_USF Excel Bonjour, Je travaille en ce moment sur un petit programme mais comme je d?bute Synth?se" ? Si vous avez une id?e. . . Merci et bon r?veillon ! Th?o Excel - French Discussions Userform1.Combobox.Value (1) Userform1.Textbox1.value (1) MEsJO405HF (1) VBA (1) ListBoxB dois la rajouter mets ?? jour dans la ligne de code du bouton validation du userform : Sheets("Synth??se").Range("F" & Ligne) = Sheets("BDonn??es").Range("B" & i) la partie : Sheets("BDonn??es").Range("B" & i) et supprimes la c??te en d??but Fais des tard. . . Th??o FFO, Peux tu m'expliquer pourquoi i = 2 et Do While i < Sheets("BDonn??es").Range("P65535").End(xlUp).Row + 1 ? A+ Th??o J'ai une question non les suivantes ! Sais-tu pourquoi ? A+ Th??o Rebonjour ?? toi et Do While i < Sheets("BDonn??es").Range("D65535").End(xlUp).Row + 1 " J'ai r??alis?? une boucle en colonne D qui est non vide ce que veux dire la ligne : Do While i < Sheets("BDonn??es").Range("D65535").End(xlUp).Row + 1 Tour ?? tour donc je me sers de
Lignes visibles d'apres liste deroulante Excel Bonjour à toutes les bonnes ames disponibles. . . j'ai 2 feuilles sur la premiere liste Visible = True Else Feuil2!Rows(i).Visible = False next i Merci de votre aide Lionel Excel - French Discussions Excel 2003 (1) VBA (1) XlCellTypeVisible (1) EntireColumn.Hidden (1) EntireRow.Hidden (1) FilterDataBase (1) RebonsoirJe mal lu la question For i = 2 To 196 If Range("a" & i) = "Oui" Then Sheets("Feuil2").Rows(i).EntireRow.Hidden = True Else Sheets("Feuil2").Rows(i).EntireRow.Hidden = False Next i Philippe Lionel a ?crit : re - Bonjour D ai pourtant juste redonné le vrai nom des feuilles. . . For i = 2 To 196 If Sheets("Liste Produits").Range("a" & i) = "Oui" Then Sheets("Feuille de comptage stock").Rows(i).EntireRow.Hidden = False Else Sheets("Feuille de comptage stock").Rows(i).EntireRow.Hidden = True Next i Par ailleurs comment ajouter
Sélection première cellule non vide -> dernière non vide Excel , dernière, non, vide" / > Salutatous et toutes, Je veux pourtant faire quelque chose de tout simple : À partir d'une cellule active quelconque, sélectionner par macro la plage s'étendant de la première cellule non vide de la colonne contenant la Cells(L1, col), Cells(L2, col)).Select End Sub Qu'en pensez-vous ? A+ Serge Excel - French Discussions Excel 2007 (1) Excel (1) Error (1) ISBLANK (1) Macro (1) Bool (1) Proc (1) MIN (1) salut Serge, L1 = Columns(ActiveCell.Column).SpecialCells(xlCellTypeConstants, 23)(1).Address L2 = Cells(65536, ActiveCell.Column).End(xlUp).Address Range(L1