Convert a date to text and protect that column

gilbertbyproxy

New Member
Joined
Jun 11, 2011
Messages
4
Hi All

I am failing but still trying to write a macro or formula to change NOW() in to text, in a cell so when I view it in future, it will remain at the date when the data was entered in to that column.

For this I am currently using

M50=COUNTIF(M5:M49,"")
M4=IF(M50<>44,NOW(),"")

The following week I and or others are entering data into the next column only and so on. All the dates are in Range("F4:IK4")

I also need to protect the last/all previous columns containing data when I close the workbook.

I have tried a circular formula for the date but other people need to input data as well and it reminds you that it is there all the time.

M4=IF(AND(M4="",NOT(ISBLANK(M7))),NOW(),IF(ISBLANK(M7),"",M4))

I unsuccessfully tried a macro for the date

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Range("F4:IK4").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=True, Transpose:=False
End Sub

but this removes the formulas from the cells to be filled in at a later date.

Unfortunately I don't have access to the workbook until the 16th June.

Thanks in advance. :)
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
something like this:
Code:
With Sheets("sheet1") 'adjust sheet name
    .Protect userinterfaceonly:=True    ' this may already be elsewhere in another module.
    For Each cll In .Range("F4:IK4").Cells
        If cll.Value <> "" Then 'if is not empty then…
            cll.Value = cll.Value 'fix the value
            cll.Resize(46).Locked = True 'lock the cell and the ones below it.
        End If
    Next cll
End With
 
Upvote 0
Sorry to pester you again but I have to password the sheets but I am missing something, can you help?
This is what I have so far......
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet 1", "Sheet 2").Unprotect Password:="password"
With Sheets("Sheet 1")
For Each cll In .Range("F4:IK4").Cells
If cll.Value <> "" Then
cll.Value = cll.Value
cll.Resize(46).Locked = True
End If
Next cll
End With
With Sheets("Sheet 2")
For Each cll In .Range("F4:IK4").Cells
If cll.Value <> "" Then
cll.Value = cll.Value
cll.Resize(33).Locked = True
End If
Next cll
End With
Sheets("Sheet 1", "Sheet 2").Protect Password:="password"
End Sub
 
Upvote 0
Cracked it :laugh:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet 1").Unprotect Password:="password"
Sheets("Sheet 2").Unprotect Password:="password"
With Sheets("Sheet 1")
For Each cll In .Range("F4:IK4").Cells
If cll.Value <> "" Then
cll.Value = cll.Value
cll.Resize(46).Locked = True
End If
Next cll
End With
With Sheets("Sheet 2")
For Each cll In .Range("F4:IK4").Cells
If cll.Value <> "" Then
cll.Value = cll.Value
cll.Resize(33).Locked = True
End If
Next cll
End With
Sheets("Sheet 1").Protect Password:="password"
Sheets("Sheet 2").Protect Password:="password"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,718
Members
452,939
Latest member
WCrawford

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