|
Sub 生成对帐单(shname As String) '生成名为shname的工作表
Application.ScreenUpdating = False
On Error Resume Next '遇到错误时继续执行下面的语句
Sheet3.Visible = xlSheetVisible '解除表式sheet3隐藏
Sheet3.Select
Dim brr(1 To 20000, 1 To 5)
With Sheet1
arr = .[a1].CurrentRegion
For i = 2 To UBound(arr)
If arr(i, 2) = shname Then
n = n + 1
brr(n, 1) = arr(i, 5)
brr(n, 2) = arr(i, 4)
brr(n, 3) = arr(i, 6)
brr(n, 4) = arr(i, 7)
brr(n, 5) = arr(i, 8)
End If
Next
End With
Worksheets("表式").Copy after:=Worksheets(Worksheets.Count)
With ActiveSheet
.[b3] = shname
.Name = shname
For i = 1 To n
.Cells(4 + i, 1).Resize(1, 4) = Application.Index(brr, i)
Next
mr = 4 + n + 2
.Cells(mr, 1) = "合计"
.Cells(mr + 2, 2) = "制表人:*****"
.Cells(mr + 2, 3) = "复核人:"
.Cells(mr + 1, 4) = "打印日期:" & Now()
.Cells(mr + 1, 1) = "【*******有限公司】"
.Cells(mr, 3).Formula = "=sum(r5c:r[-1]c)"
.Cells(mr, 4).Formula = "=sum(r5c:r[-1]c)"
.Cells(mr, 5) = .Cells(mr, 4) - .Cells(mr, 3)
'.Rows("5:" & mr + 2).RowHeight = 20 '设置行高
.Range("A5:A" & mr - 2).NumberFormatLocal = "yyyy/m/d" '设置日期格式
Set mrng = .Range("A4:E" & mr)
mrng.Borders.LineStyle = xlContinuous '划线
mrng.HorizontalAlignment = xlCenter '居中
End With
Sheet7.Activate
Application.ScreenUpdating = True
End Sub
当源数据表中摘要的字符超过255个字符时,按合同号查询时无法正确显示。255个字符以内的,查询正确显示。图中合同号A-222摘要字符255个字符以内,查询正确显示;合同号B-111中摘要超过255个字符,显示为空白表。请老师帮忙看看问题出在哪?有没有办法可解决?
|
|