Forum Discussion
help with a formula - order data was entered
- Oct 15, 2020
I have used VBA to achieve the desired output.
Right click on Sheet1 Tab --> View Code to see the code.
The code is for Sheet Change Event so that once you input a qty in column B and if the corresponding cell in column A is not empty it would place the desired order sequence# in corresponding cell in column C.
Code:
Private Sub Worksheet_Change(ByVal Target As Range) If Target.CountLarge > 1 Then Exit Sub On Error GoTo Skip If Target.Column = 2 And Target.Row > 1 Then Application.EnableEvents = False If Target.Offset(0, -1) <> "" Then If Target <> "" Then Target.Offset(0, 1).Value = Application.Count(Range("B:B")) Else Target.Offset(0, 1).Value = "" End If End If End If Skip: Application.EnableEvents = True End SubTo test the code, input qty in column B in the attached and see if column C gets populated with the desired output.
I have used VBA to achieve the desired output.
Right click on Sheet1 Tab --> View Code to see the code.
The code is for Sheet Change Event so that once you input a qty in column B and if the corresponding cell in column A is not empty it would place the desired order sequence# in corresponding cell in column C.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
On Error GoTo Skip
If Target.Column = 2 And Target.Row > 1 Then
Application.EnableEvents = False
If Target.Offset(0, -1) <> "" Then
If Target <> "" Then
Target.Offset(0, 1).Value = Application.Count(Range("B:B"))
Else
Target.Offset(0, 1).Value = ""
End If
End If
End If
Skip:
Application.EnableEvents = True
End SubTo test the code, input qty in column B in the attached and see if column C gets populated with the desired output.
- Subodh_Tiwari_sktneerOct 16, 2020Silver Contributor
You're welcome subash758! Glad it worked as desired.