Hello all,
Here is the problem I am trying to sort out.
As soon as workbook opens user is asked for an input from column C. The VBA script locates it, rthen user inputs number , which should be exactly agsinst the earlier input i.e.
if user has input Article12 , which is in column C5, the next input should be comapred to column D where the numbers of articles present .
next step based on user input for article number is to minus that number from column D ( if is it les than or equal to Number present) and then save sheets and stop user process any more/close
so far here is the the scipt I have
The code from second set cell is what am trying to improve upon.
Here is the problem I am trying to sort out.
As soon as workbook opens user is asked for an input from column C. The VBA script locates it, rthen user inputs number , which should be exactly agsinst the earlier input i.e.
if user has input Article12 , which is in column C5, the next input should be comapred to column D where the numbers of articles present .
next step based on user input for article number is to minus that number from column D ( if is it les than or equal to Number present) and then save sheets and stop user process any more/close
so far here is the the scipt I have
VBA Code:
Private Sub Workbook_Open()
Dim Arnum As Variant
Dim Count As Variant
Dim Sheetname As String
Arnum = InputBox("Please input article number :", "Input")
Count = InputBox(" Please input number of articles wanted", "Input")
Sheetname = "list1"
Dim Cell As Variant
Set Cell = Sheets(Sheetname).Columns("C:C").Find(What:=Arnum, After:=Sheets(Sheetname).Range("C1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not Cell Is Nothing Then
Sheets(Sheetname).Range(Cell.Address).Interior.ColorIndex = 4
Else
'Value Not found
MsgBox "Wrong article number"
End If
Set Cell = Sheets(Sheetname).Columns("F:F").Find(What:=Count, After:=Sheets(Sheetname).Range("F1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False)
If Not Cell Is Nothing Then
'Value is found, Highlight Cell
Sheets(Sheetname).Range(Cell.Address).Interior.ColorIndex = 5
Else
'Value Not found
MsgBox "This is more than what we have "
End If
End Sub
The code from second set cell is what am trying to improve upon.