Excel VBA 宏

Excel VBA 宏

我需要以下问题的帮助:- 当有一个空行时,我希望下一个数据填充这些空行,我希望数据行 16 移动到空行 13 在此处输入图片描述

For C1 = 1 To 273 Step 46

For B1 = C1 + 4 To C1 + 5
Cells(B1, 6) = ""
Next B1

Cells(C1 + 4, 2) = ""


For B3 = C1 + 11 To C1 + 35     'range Row for description
For B4 = 1 To 6                 'range Column for description
Cells(B3, B4) = ""
Next B4
Next B3

Next C1


X1 = 12: X2 = 1: Cells(4, 11) = 1
For N1 = 3 To 10000
If Cells(2, 10) = Worksheets("Sheet1").Cells(N1, 1) Then


   If X2 = 1 Then
    For D1 = 1 To 273 Step 46
   
     Cells(D1 + 4, 6) = Worksheets("Sheet1").Cells(N1, 2)  'Date
     Cells(D1 + 5, 6) = Worksheets("Sheet1").Cells(N1, 1)  'PO Number
     Cells(D1 + 4, 2) = Worksheets("Sheet1").Cells(N1, 4)  'Attn To
     Cells(D1 + 5, 2) = Worksheets("Sheet1").Cells(N1, 3)  'Supplier Name
     
    Next D1
    
     
  End If
  

     If X1 = 36 Then
     X1 = 58: Cells(4, 11) = Cells(4, 11) + 1
     End If
     
     If X1 = 81 Then
     X1 = 104: Cells(4, 11) = Cells(4, 11) + 1
     End If
     
     If X1 = 127 Then
     X1 = 150: Cells(4, 11) = Cells(4, 11) + 1
     End If
     
     If X1 = 172 Then
     X1 = 196: Cells(4, 11) = Cells(4, 11) + 1
     End If
   
     Cells(X1, 1) = X2 & "."
     Cells(X1, 2) = Worksheets("Sheet1").Cells(N1, 5)              'Item Description 1
     Cells(X1 + 1, 2) = Worksheets("Sheet1").Cells(N1, 6)        'Item Description 2
     Cells(X1 + 2, 2) = Worksheets("Sheet1").Cells(N1, 7)          'Item Description 3
     Cells(X1 + 3, 2) = Worksheets("Sheet1").Cells(N1, 8)          'Item Description 4
     Cells(X1, 3) = Worksheets("Sheet1").Cells(N1, 15)              'Qty
     Cells(X1, 4) = Worksheets("Sheet1").Cells(N1, 16)              'U/M
     Cells(X1, 5) = Worksheets("Sheet1").Cells(N1, 17)              'U/Price
     Cells(X1, 6) = Worksheets("Sheet1").Cells(N1, 18)              'Total Amount
     
    X1 = X1 + 4: X2 = X2 + 1
 
  
End If
    
Next N1

相关内容