宏:将数据插入另一个空表,不会插入

时间:2016-02-17 08:49:51

标签: excel vba excel-vba

我想将数据插入到一个新的空白表中,但是当我定义循环来读取新表时,它将不会进行插入。

  

我执行第一个 For 来定义空工作表,第二个 For 来读取包含数据的工作表的数据。   然后我做逻辑。但我不会进行输入。   怎么了?我需要重置空白纸吗?

`

For i= 2 To last_row(ws_EmptySheet)

   For j = 2 To last_row(ws_Data)

       Set Range_Data = ws_Data.Range("A" & j, "N" & Rows.Count)

If ws_Data.Range("D" & j) = 3 Then

supplier = ws_Data.Range("A" & j) ind = j indF = j + 1

For Each supplier In ws_Data


state = ws_Data.Range("K" & ind, "N" & Rows.Count).Find(What:="State", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Offset(0, 3)
  If (state<> "") Then
       r = ws_Data.Range("K" & ind, "N" & Rows.Count).Find(What:="Nazione", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Row

'IndI = r

    Set rngEmpty = ws_EmptySheet.Range("A" & i)

    i2 = i

i = i + 1

indF = indF + 1

On Error Resume Next

If Err.Number <> 0 Then

rngEmpty = ""

 Else

supplier = ws_Data.Range("A" & r)

supplierEmpty = ws_EmptySheet.Cells(1, 1).EntireRow.Find(What:="STATE", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Column rngEmpty.Offset(0, supplierEmpty - 1) = supplier

city = ws_Data.Range("B" & r, "N" & indF)

cityEmpty = ws_AltreSedi.Cells(1, 1).EntireRow.Find(What:="CITY", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Column rngEmpty.Offset(0, cityEmpty - 1) = city

End If

     End If

      Next

       End If
     j = j + 1
  Next

`

1 个答案:

答案 0 :(得分:0)

为什么 来定义空表。如果你创建一个新的空白表,我只是重新编写它的号码或名称。