Excel 从单元格中减去文本框值
我有一张清单。Excel 从单元格中减去文本框值,excel,vba,textbox,cell,subtraction,Excel,Vba,Textbox,Cell,Subtraction,我有一张清单。 当研究人员在特定批次中获取数量时,该数量首先从库存数量中移除,即第8列ComboBox1的特定行。那部分没关系 当获取第二个数量且批次的行不为空时,我将数据放在下面的一行中,但我希望数量(textBox2)减到ComboBox1行的第8列 我会考虑使用iFound可能.Cells(iFound-1,8).Value=ComboBox2.Value=.Cells(iFound-1,8).Value-ComboBox2.Valuethe-1我认为您还需要计算,因为这将增加Hi Na
当研究人员在特定批次中获取数量时,该数量首先从库存数量中移除,即第8列ComboBox1的特定行。那部分没关系 当获取第二个数量且批次的行不为空时,我将数据放在下面的一行中,但我希望数量(textBox2)减到ComboBox1行的第8列
我会考虑使用iFound可能
.Cells(iFound-1,8).Value=ComboBox2.Value=.Cells(iFound-1,8).Value-ComboBox2.Value
the-1我认为您还需要计算,因为这将增加Hi Nathan_Sav,这不起作用,它似乎不是一个有效的公式。我也遇到了一些问题,我的消息错误,它出现的所有时间,我不明白它的工作时,所有的行被填补,但不再是当我清除内容,使其他测试。。。我是不是忘了说我在编程方面比较新?我说过你需要玩它。使用逐步调试来检查代码,查看值是什么。它现在可以与代码ws.Cells(iFound-1,8)一起工作。Value=ws.Cells(iFound-1,8)。Value-TextBox2.Value感谢Nathan_Sav的帮助!!
Private Sub CommandButton1_Enter()
Dim emptyRow As Long
Dim ws As Worksheet
Set ws = ActiveSheet
ActiveSheet.Name = "Micrux"
Dim iLastRow As Long, iFound As Long
Dim rng, bEmpty As Boolean, c As Integer
Dim Test As Boolean
bEmpty = True
With ws
iLastRow = .Range("A" & .Rows.Count).End(xlUp).Row
Set rng = .Range("A1:A" & iLastRow + 1).Find(ComboBox1.Value, _
After:=.Range("A" & iLastRow + 1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
SearchDirection:=xlPrevious)
Test = (TextBox2.Text) > ws.Cells(iLastRow, 8)
If Test = True Then
MsgBox "Not enough quantity in stock!"
Else
If rng Is Nothing Then
iFound = iLastRow + 1
Else
iFound = rng.Row
For c = 4 To 7
If Len(.Cells(iFound, c)) > 0 Then bEmpty = False
Next
If bEmpty = False Then
iFound = iFound + 1
.Cells(iFound, 1).EntireRow.Insert xlShiftDown
.Cells(iFound, 7).Value = TextBox2.Text
.Cells(iFound, 6).Value = TextBox3.Text
.Cells(iFound, 5).Value = ComboBox2.Value
.Cells(iFound, 4).Value = TextBox1.Text
Else
.Cells(iFound, 7).Value = TextBox2.Text
.Cells(iFound, 6).Value = TextBox3.Text
.Cells(iFound, 5).Value = ComboBox2.Value
.Cells(iFound, 4).Value = TextBox1.Text
End If
End If
End If
End With
Unload Me
End Sub