VBA program help required

myasir1992

New Member
Joined
May 12, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Hello Everybody,
I have created a VBA program where I have a sheet named "Purchase Roll". I have a data validation that includes
1.) Store Location.
2.) Supplier No.
3.) Rate Selection.
4.) Invoice/Bill No.
5.) Date.

I have 2 questions:
1.) My question is regarding #3 Rate selection where I have 2 choices for the user i.e. "From the price list" or "Manual". Now if user selects "From the price list" the serial number that is showing in the Document No. appears but when somebody selects "Manual" nothing appears. Why?
2.) Another question is when somebody selects "From the price list" it displays the serial number which the system should be getting from the cell # AA1 but it is picking some random number.

Kindly resolve these 2 issues as soon as possible. I will be very grateful to you.
Waiting for your response.
 

Attachments

  • 1652799848508.png
    1652799848508.png
    165.1 KB · Views: 12
  • 2022-05-17 (1).png
    2022-05-17 (1).png
    164.3 KB · Views: 12

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
You need to show the code you used
 
Upvote 0
Here is the code:
Private Sub Worksheet_change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Intersect(Target, Range("E12:E35")) Is Nothing Then Exit Sub
Dim fnd As Range
If Range("F9") = "From the price list" Then
Set fnd = Range("O12:O35").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
If Not fnd Is Nothing Then
Target.Offset(, 5) = fnd.Offset(, 1)
Call Worksheet_Purchasereel(Target)
End If
End If
End Sub

Private Sub Worksheet_Purchasereel(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
Application.EnableEvents = False
With Sheets("Database").Cells(Rows.Count, "A").End(3)
If .Value = "Document No." Then
[D12:D35] = [AA1]
Else: [D12:D35] = .Value + 1
End If
End With
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top