ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Required cell content (https://www.excelbanter.com/excel-programming/374792-required-cell-content.html)

Catlady

Required cell content
 
I need to be able to require a person to put initials in the row they are
entering or modifying. Is there a way to make Excel not save until this
information is added?

Gary''s Student

Required cell content
 
Let's say your user is entering data in some row in Sheet1 and you want the
initiials in column A.

In worksheet code (for Sheet1) enter:

Private Sub Worksheet_Change(ByVal Target As Range)
myrow = Target.Row
End Sub

This will capture the user's row

In a standard module enter:

Public myrow As Long

This make myrow static & public

In ThisWorkbook code enter:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim mycell As Range
Dim s As String
s = "A" & myrow
Set mycell = Sheets("Sheet1").Range(s)
If IsEmpty(mycell.Value) Then
mycell.Value = InputBox("enter initials: ")
End If
End Sub

So the worksheet code captures the row in which the userentered data.
The ThisWorkbook code uses the row information to test for and propt for the
initials.
--
Gary''s Student


"Catlady" wrote:

I need to be able to require a person to put initials in the row they are
entering or modifying. Is there a way to make Excel not save until this
information is added?



All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com