用VBA 将表格中每个有数据的单元格提取一行数据出来,最后生成一个代码。如果一行有4,就换行。 10
Sub生成()DimiAsLongDimjAsLongDimTAsStringDimQAsStringDimV()AsStringi=1j=1Sheets("Sheet1...
Sub 生成()
Dim i As Long
Dim j As Long
Dim T As String
Dim Q As String
Dim V() As String
i = 1
j = 1
Sheets("Sheet1").Select
While (Len(Cells(i, j)) > 0)
For i = 1 To 100 Step 1
For j = 1 To 4 Step 1
S = Cells(i, j).Text
V = Split(S, Chr(10))
T = "111" & V(0) & & V(1) & "<222>" & V(2) & "<333>"
If j > 0 And j < 4 Then
Q = Q & T
Else
Q = Q & T & "</tr><tr>"
Sheet2.Cells(1, 1).Value = "AA" & Q & "ZZ"
End If
Next j
Next i
Wend
End Sub
哪边出错,请高手帮忙 展开
Dim i As Long
Dim j As Long
Dim T As String
Dim Q As String
Dim V() As String
i = 1
j = 1
Sheets("Sheet1").Select
While (Len(Cells(i, j)) > 0)
For i = 1 To 100 Step 1
For j = 1 To 4 Step 1
S = Cells(i, j).Text
V = Split(S, Chr(10))
T = "111" & V(0) & & V(1) & "<222>" & V(2) & "<333>"
If j > 0 And j < 4 Then
Q = Q & T
Else
Q = Q & T & "</tr><tr>"
Sheet2.Cells(1, 1).Value = "AA" & Q & "ZZ"
End If
Next j
Next i
Wend
End Sub
哪边出错,请高手帮忙 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询