Solved

limitMyEntry

Posted on 2013-01-29
3
156 Views
Last Modified: 2013-01-30
Hello All,

I am looking for a worksheet change event:

Requirements:
1.      For columns C and F, users cannot enter negative numbers
2.      If users enter negative, target.value becomes 0 and prompts users with message
3.      If user either enter numbers for C or F, the column H of that row will get TRUE for the update.

thanks
limitInput.xlsx
0
Comment
Question by:Rayne
3 Comments
 
LVL 24

Assisted Solution

by:Steve
Steve earned 200 total points
ID: 38834194
You could apply Validation rules to only allow positive numbers in a range.
This will have it's own message box.

This is in Data > Validatation > Allow > Decimal > Above > 0

See attached.
Validation.xlsx
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 300 total points
ID: 38834265
Right-click on the sheet tab name
Select View code
Paste this code in the VBA window
Close the VBA window
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count = 1 And Not Intersect(Target, Range("C4:C9,F4:F9")) Is Nothing Then
        If Target.Value < 0 Then
            Target.Value = 0
            MsgBox "Only non-negative numbers allowed", , "Warning"
        End If
        Target.EntireRow.Cells(8).Value = True
    End If
End Sub

Open in new window


*****Code edited*****
0
 

Author Closing Comment

by:Rayne
ID: 38835910
Thanks all :)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now