2016-04-04 17 views
0

Şu anda bir çalışma zamanı hatası yaşıyorum91 'Nesne Değişkeni veya Vurgulanan Kod için Belirtilen kod ayarlanmamış. Bu kodun amacı, kullanıcı formundan girdiye dayalı olarak adlandırılmış bir ürünü aramak ve ardından mevcut miktara göre saptırmaktır. Daha sonra, mevcut değeri sipariş edilen miktarla çıkararak eski değeri yeni bir değerle değiştirecektir.Eski değeri Userform girdisi temelinde yeni değerle değiştirme

Private Sub btnAdd_Order_Click() 
Dim X As Integer 
Dim nextrow As Range 
Dim DateCus As Range 
Dim i As Range 

If Me.txtOrder_No.Value = "" Then 
MsgBox "Add an Order No" 
Exit Sub 
End If 

If Me.Order1.Value = "" And Me.Qty1.Value = "" Then 
MsgBox "No order was specified. Please input an order" 
Exit Sub 
Else 
For X = 1 To 8 

Set nextrow = Sheet6.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) 
If Me.Controls("Order" & X).Value > "" And Me.Controls("Qty" & X).Value > "" Then 

If Me.Controls("Qty" & X).Value < Application.WorksheetFunction.VLookup(Me.Controls("Order" & X), Sheet4.Range("Products"), 4, 0) Or Me.Controls("Qty" & X).Value = Application.WorksheetFunction.VLookup(Me.Controls("Order" & X), Sheet4.Range("Products"), 4, 0) Then 

'This is the one causing the error 
Set i = Sheet3.Range("Ingredients").Find(Me.Controls("Order" & X).Value).Offset(0, 3) 

i = Application.WorksheetFunction.VLookup(Me.Controls("Order" & X), Sheet4.Range("Products"), 4, 0).Value - Me.Controls("Qty" & X).Value 



'End If 

Else 
MsgBox "There's no stock available for one of the orders" 
+0

Her zaman, hatanın hangi satıra neden olduğunu not etmenize yardımcı olur. –

cevap

0

de

Set nextrow = Worksheets("Sheet6").Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) 

ve beğeni ("Sheet3", "Sheet4", ...) ile

Set nextrow = Sheet6.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) 

yerine deneyin.

İlgili konular