|
将图片1格式转换成图片2格式,如该农户家庭成员只有一人,也就是只有一个户主时,无法转换,如何修改代码。原代码如下
- Option Explicit
- Sub test()
- Dim arr, i&, m&, r&
- With Sheet1
- r = .Cells(Rows.Count, 4).End(3).Row
- arr = .Range("A2:E" & r)
- End With
- ReDim brr(1 To UBound(arr), 1 To 5)
- m = 1
- For i = 1 To UBound(arr)
- If arr(i, 2) = "户主" Then
- brr(m, 1) = arr(i, 5)
- brr(m, 2) = arr(i, 3)
- brr(m, 3) = arr(i, 4)
- Else
- brr(m, 4) = arr(i, 3)
- brr(m, 5) = arr(i, 4)
- m = m + 1
- End If
- Next
- With Sheet2.[a3]
- .CurrentRegion.Offset(3).ClearContents
- .Resize(m, 5) = brr
- End With
- End Sub
复制代码
户籍资料格式转换 (1).rar
(19.76 KB, 下载次数: 7)
|
|