Sub Macro1()
Set myrng = Range("A1").CurrentRegion
Dim aa As String
For i = 2 To 101
For j = 5 To myrng.Columns.Count
If myrng.Cells(i, j).Text <> "" Then
aa = myrng.Cells(1, j).Value
End If
Next
myrng.Cells(i, 3).Value = aa
Next
End Sub
本文介绍了一个VBA宏代码示例,该宏用于将Excel表格中特定区域的第5列到最后一列的数据复制到第3列,并在过程中进行相应的数据处理。通过设置变量和循环遍历的方式实现了数据的有效转移。
Sub Macro1()
Set myrng = Range("A1").CurrentRegion
Dim aa As String
For i = 2 To 101
For j = 5 To myrng.Columns.Count
If myrng.Cells(i, j).Text <> "" Then
aa = myrng.Cells(1, j).Value
End If
Next
myrng.Cells(i, 3).Value = aa
Next
End Sub
1万+

被折叠的 条评论
为什么被折叠?
