|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
求助!关于含有合并单元格的word表格替换及换算,将“亩”替换为“公顷”
此前在老师的启发和帮助下,有了一个代码,因为始终无法解决合并单元格问题,原以为SelectColumn等方法可以解决,谁知还是解决不了,都快丧失信心了!恳请各位高手看一看,还应该怎样修改或者。。。才能解决
Sub 含合并单元格的查找与换算示例1()
Dim t As Table, r&, c&, temp As String, v As String, temp1 As String, temp2 As String
On Error Resume Next '忽略错误
For Each t In ActiveDocument.Tables
For c = 1 To t.Columns.Count
temp = t.Cell(2, c).Range.Text
If InStr(temp, "亩") > 0 Then
t.Cell(2, c).Range.Text = Replace(temp, "亩", "公顷")
temp1 = t.Cell(1, c).Range.Text
If InStr(temp1, "亩") > 0 Then
t.Cell(1, c).Range.Text = Replace(temp1, "亩", "公顷")
End If
For r = 3 To t.Rows.Count
v = t.Cell(r, c).Range.Text
t.Cell(r, c).Range.Text = Round((Val(v) * 0.06667), 2)
Next
End If
temp2 = t.Cell(1, c).Range.Text
If InStr(temp2, "亩产") > 0 Then
ElseIf InStr(temp2, "亩") > 0 Then
t.Cell(1, c).Range.Text = Replace(temp2, "亩", "公顷")
For r = 2 To t.Rows.Count
v = t.Cell(r, c).Range.Text
t.Cell(r, c).Range.Text = Round((Val(v) * 0.06667), 2)
Next
End If
Next
Next
MsgBox "Completed!"
End Sub
|
|