根据条件通过VBA添加行

时间:2019-09-04 11:16:12

标签: excel vba

我使用VBA代码向违约者发出信件。数据按产品进行维护。如果Person1必须为产品1付费,则打印出SHEET2(具有从其他几张纸上获取的数据) 如果同一人必须为product2付款,它将打印第二个字母。 我正在寻找一种解决方案,如果有人重复该代码,则应在现有字母上添加一行。

Sub Complaintexporter()

Dim X As Integer
Dim rng As Range


X = 3
Do Until IsEmpty(Sheet1.Cells(X, 29))

If Sheet1.Cells(X, 29) = "Legal Issued to Exporter" And Date - Sheet1.Cells(X, 36) > 21 Then
Sheet9.Cells(1, 1) = Sheet1.Cells(X, 4)
Set rng = Sheet1.Cells(X, 4)
'
'Sheet1.Activate
'    Cells.Find(What:=Sheet9.Cells(1, 1), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
'        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
'        , SearchFormat:=False).Activate
       'Remarks
        Sheet1.Cells(X, 4).Offset(0, 25).Value = "Pending In FEA Court"
        'FEAD/FEOD
        Sheet1.Cells(X, 4).Offset(0, 24).Value = "FEAD"
        'Details Penalty
        Sheet1.Cells(X, 4).Offset(0, 26).Value = "Pending In FEA Court"
        'year
        Sheet1.Cells(X, 4).Offset(0, 28).Value = "2019"
        'Complaint against
        Sheet1.Cells(X, 4).Offset(0, 29).Value = "Exporter"
        'Complainant/ Officer
        Sheet1.Cells(X, 4).Offset(0, 36).Value = Sheet1.Cells(1, 4)
        'Complaint No
        Sheet1.Cells(X, 4).Offset(0, 27).Value = Sheet2.Cells(1, 2)
        'Date of complaint against exporter
        Sheet1.Cells(X, 4).Offset(0, 34).Value = Date

Sheet4.PrintOut
Sheet5.PrintOut
Sheet6.PrintOut

'Write E-Form in list
Sheet2.Cells(Sheet2.Cells(1, 1), 2) = Sheet9.Cells(1, 1)
'Write Date against E-Form
Sheet2.Cells(Sheet2.Cells(1, 1), 3) = Date
'Increasing Serial No.
Sheet2.Cells(1, 1) = Sheet2.Cells(1, 1) + 1
'Increasing Complaint No.
Sheet2.Cells(1, 2) = Sheet2.Cells(1, 2) + 1

End If
X = X + 1
Loop
MsgBox Sheet2.Cells(12, 9)
End Sub

0 个答案:

没有答案