|
代码中没有判断第一行中的内容是否是合法的列标,
所以第一行的内容,只能自己手工输入时校验好!
如附件中的数据,当代码运行到 E1 时,则会提示错误!!
- Sub cc()
- Dim Lx As Integer, L As Integer, Hx As Integer
- Dim Co As String
- L = 15
- With Sheets("Sheet2")
- For Lx = 1 To Range("A1").End(xlToRight).Column
- Co = Cells(1, Lx).Value
- Hx = .Cells(1, Co).End(xlDown).Row
- Cells(1, L).Resize(Hx).Value = .Range(.Cells(1, Co), .Cells(Hx, Co)).Value
- L = L + 1
- Next
- End With
- End Sub
复制代码 |
评分
-
查看全部评分
|