BeforeClose/ BeforeSave - required fields

triangulo

New Member
Joined
Dec 3, 2010
Messages
21
Hi all! I would like to add a script that forces the user to edit certain fields upon saving/closing the workbook. In the "Revision history" sheet, I've added a script that populates the date and author columns automatically, when Description and revision fields are edited. Se code below.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Me.Cells(Target.Row, "A") = Date
    Me.Cells(Target.Row, "B") = Environ("UserName")
    Application.EnableEvents = True
End Sub
A B C D
Date Author Description Revision
26-Nov-2010 user1 Draft 0.1
13-Jan-2011 user2 aaa 0.2
17-Jan-2011 user2 xxx 0.3
...
I don't want the user to edit all the fields in the C and D columns, just on the next row after the last added row. Is that possible? I'm thinking an offset and count function but I can't get it to work properly.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,424
Messages
6,119,401
Members
448,893
Latest member
AtariBaby

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