Link to home
Start Free TrialLog in
Avatar of singleton2787
singleton2787

asked on

Populate one sheet based on vlaues in another sheet

This has been asked before, but I couldn't find the exact answer I was looking for..
In the sheet 'Template Requirements' there are some cell with 'n/a' in them. I simply want to populate the sheet 'Data' with JUST the 'N/A' values and make the 'N/A' cells prohibited from changing (i.e. entering data).
dashboard-wipv3a.xlsm
Avatar of Eric Zwiekhorst
Eric Zwiekhorst
Flag of Netherlands image

Hi Singleton,

I do not understand what you mean with:

I simply want to populate the sheet 'Data' with JUST the 'N/A' values and make the 'N/A' cells prohibited from changing (i.e. entering data).
   
Do you want the possibility to enter data in the N/A filled field just one time, and after that they should be locked?

this is feasable...

Kind reagrds

Eric
Try lock the sheet and leaving unlocked the N/A values.

then put in the sheet macro
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
 Dim myString As String
 Dim cel As Range, TARG As Range
 Dim KOLOM As Integer
Application.EnableEvents = False
On Error Resume Next
Set TARG = Intersect(Target, Range("3:10"))     'Obviously you can change this target range to your desired range
KOLOM = TARG.Column
 If TARG Is Nothing Then
   Application.EnableEvents = True
   Exit Sub
   Else
   myString = TARG
End If
If TARG.Locked = False Then TARG.Locked = True
End Sub


kind regards

Eric
Avatar of McOz
McOz

You could use formulas to populate the N/A values in the Data sheet, then run some code like this in the WorkSheet_Activate event or similar:
Private Sub Worksheet_Activate()
    ActiveSheet.Unprotect
    For Each c In ActiveSheet.UsedRange.Cells
        If c.Value = "N/A" Then c.Locked = True Else c.Locked = False
    Next
    ActiveSheet.Protect
End Sub

Open in new window


Good luck!
Avatar of singleton2787

ASKER

Zwie, I get an unexpected End Sub on the macro...
McOZ, how do I activate this code??
ASKER CERTIFIED SOLUTION
Avatar of McOz
McOz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bravo!!