Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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).
  • 3
  • 2
  • 2
1 Solution
Eric ZwiekhorstSAP Business ConsultantCommented:
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 ZwiekhorstSAP Business ConsultantCommented:
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
 If TARG Is Nothing Then
   Application.EnableEvents = True
   Exit Sub
   myString = TARG
End If
If TARG.Locked = False Then TARG.Locked = True
End Sub

kind regards

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()
    For Each c In ActiveSheet.UsedRange.Cells
        If c.Value = "N/A" Then c.Locked = True Else c.Locked = False
End Sub

Open in new window

Good luck!
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

singleton2787Author Commented:
Zwie, I get an unexpected End Sub on the macro...
singleton2787Author Commented:
McOZ, how do I activate this code??
1. Right click on the "Data" sheet tab at the bottom, and choose "View Code"
2. Copy and paste the code into the window, and save.
3. whenever you go to the Data sheet, it will automatically run this code, which locks all cells containing the value "N/A"

singleton2787Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now