选择与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 (将#修改为@)