This is specific to your example, but its a start. You could probalby make it dynamic with named ranges. Right click the sheet tab that has your data and go to view code. Paste this in there. If it doesnt work they way you want, maybe the concepts will help. It also has a potential downfall. If you click cancel on the input box, you can then type anything you want in the selected cell and it will not run the code. I suppose you could put the same code in a worksheet_change event to catch that.
Code:Sub worksheet_selectionchange(ByVal Target As Range) Dim inval As Integer On Error GoTo err: If Intersect(Target, Range("J48:P49")) Is Nothing Then 'Selection not in range Else Prompt: inval = InputBox("Enter a Value for " & Target.Address) If inval = 0 Then Exit Sub If IsNumeric(inval) = False Then MsgBox "Invalid entry, must be a number" GoTo Prompt Else If Target.Row = 49 Then Target = inval Else If inval < Target Then Target = inval Else If Range("Q48").Value + inval >= 25000 Then Target = 25000 + Target - Range("Q48").Value Target.Offset(1, 0) = inval - Target Else Target = inval End If End If End If End If End If Exit Sub err: If err.Number = 13 Then Exit Sub 'Cancel or Alpha was entered Call MsgBox(err.Description, , err.Number) End Sub


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks