PDA

View Full Version : i want to validate users entered value with existing range in another sheet



divys
01-10-2017, 05:55 AM
I want to create a program in which "current stock" sheet has range of data, located in column C and user will add new data, in "consumption sheet" column D, which may or may not be the same as entered in "current stock". So i want to check if user's entered value is same as the value one of cell of range of my "current stock" sheet.
Their is one another question. The question is their any way in application. inputbox such that i can use value before "." and use that value to store in another cell?


Sub consumption()
Dim counter As Integer
Dim i As Integer
Dim x As Integer
Dim ws As Worksheet
Dim wc As Worksheet
Dim rangs As Range, rangc As Range
Dim plate As Integer
Set ws = ThisWorkbook.Worksheets("current stock")
Set wc = ThisWorkbook.Worksheets("consumption")
Cells(i, 3).Value = Application.InputBox(prompt:="Entre a Dwg No.", Type:=2)
plate = Application.InputBox(prompt:="Entre a plate code:", Type:=2)
Set rangs = ws.Range("c4:c128")
With rangs.Validation
.Delete
.Add xlValidateList, xlvalidalerstop, xlBetween, rangs, plate
End With

SamT
01-11-2017, 10:24 AM
use value before "."
Two ways:
Use the first item in a Split array

Use Instr to find the location of the "." then use Left to return the value up to the "."