微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

选择与excel vba中选定行相对应的单元格

如何解决选择与excel vba中选定行相对应的单元格

我正在编写一个与“supprimer”(清除)按钮相关的宏,该宏只清除特定单元格((对应行,C),(对应行,E))中与账单中特定行相对应的数据(与用户表单中组合框“Choisir une référence”中的引用匹配的行),以便计算总价和搜索商品名称的公式不受影响。

代码如下:

[![Private Sub ajouter_Click()
Dim ligne As Integer: ligne = 2
Dim lignef As Integer: lignef = 6

If (liste_ref.SelText <> "") Then
If (IsNumeric(quantite.Value) = False) Then
MsgBox ("La quantité saisie n'est pas un nombre,veuillez corriger")
Exit Sub
Else
While (ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value <> "")
If (ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value = liste_ref.SelText) Then
If (Int(quantite.Value) > Int(ThisWorkbook.Worksheets("articles").Cells(ligne,6).Value)) Then
MsgBox "La quantité en stock pour cette référence n'est que de " & ThisWorkbook.Worksheets("articles").Cells(ligne,6).Value
Exit Sub
Else
While (ThisWorkbook.Worksheets("facturation").Cells(lignef,3).Value <> "")
lignef = lignef + 1
Wend
ThisWorkbook.Worksheets("facturation").Cells(lignef,3).Value = liste_ref.SelText
ThisWorkbook.Worksheets("facturation").Cells(lignef,5).Value = quantite.Value
End If
End If

ligne = ligne + 1
Wend
End If
End If
End Sub

Private Sub liste_ref_Change()

End Sub

Private Sub reinitialiser_Click()
ThisWorkbook.Worksheets("facturation").Activate
Range("C6:C26").Value = ""
Range("E6:E26").Value = ""
End Sub

Private Sub supprimer_Click()
ThisWorkbook.Worksheets("facturation").Activate
Rows(\[C6:C1048576\].Find(liste_ref.Value).Row).Cells(thisrow,3).Value = ""
Rows(\[C6:C1048576\].Find(liste_ref.Value).Row).Cells(thisrow,5).Value = ""

End Sub

Private Sub UserForm_Activate()

Dim ligne As Integer: ligne = 2

While (ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value <> "")

liste_ref.AddItem (ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value)
ligne = ligne + 1

Wend

ThisWorkbook.Worksheets("facturation").Activate

End Sub

Private Sub valider_Click()
Dim reponse As Byte
Dim ligne As Integer: ligne = 2
Dim lignef As Integer: lignef = 6

reponse = MsgBox("Souhaitez-vous valider la facture et mettre à jour les stocks",vbYesNo + vbQuestion)

If (reponse = 6) Then
While (ThisWorkbook.Worksheets("facturation").Cells(lignef,3).Value <> "")
ligne = 2
While (ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value <> "")

If (ThisWorkbook.Worksheets("facturation").Cells(lignef,3) = ThisWorkbook.Worksheets("articles").Cells(ligne,3).Value) Then
ThisWorkbook.Worksheets("articles").Cells(ligne,6).Value = ThisWorkbook.Worksheets("articles").Cells(ligne,6).Value - ThisWorkbook.Worksheets("facturation").Cells(lignef,5)
End If
ligne = ligne + 1
Wend
lignef = lignef + 1
Wend

msg.Caption = "Les stocks ont été mis jour. La facture peut être éditée."

End If

End Sub][1]][1]

问题是代码清除了帐单的标题

以及如何使帐单动态化,以便在我清除一行时其他项目向上移动?

enter image description here

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。