excel问题提问?

blackicewolf 2002-11-22 11:50:41
将数据导出到excel中,其中有些字段的内容是重复的,比如:我有时间字段,每天有多条记录,我现在只需将这个时间字段的内容在报表中只显示一次,相当于合并单元格,这在程序中怎么控制,哪里有这样的例子?
谢谢!
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
XiaoDao 2002-12-03
  • 打赏
  • 举报
回复
Sub MakeSheet(ByVal N As String, C As Integer, pY As Integer, hbC As Integer)
'适用性: 最大行数:500,第一列无空格,最大到N列,题头3行
'参数含义: N:sheet表名 pY:每页行数(除题头) C:字段数 Colu:要合并的列数
Dim r1 As Integer '当前对比起始行,合并时用
Screen.MousePointer = vbHourglass
Set wSheet = AppExcel.Worksheets(N)
With wSheet
.Range("a4:n500").ClearContents
.Range("a4:n500").MergeCells = False
.Cells(1, 1) = SBar.Panels(1).Text
grRs.MoveFirst
For i = 1 To grRs.RecordCount
For j = 1 To C
.Cells(3 + i, j) = grRs.Fields(j - 1).Value
Next j
grRs.MoveNext
Next
'以下为合并单元格部分
If hbC > 0 Then
For p = 4 To 500 Step pY
For Colu = hbC To 1 Step -1 '列
r1 = p
For r = p + 1 To p + pY - 1 '行
If .Cells(r, 1) = "" Then Exit For '第一列无数据,退出
If .Cells(r, Colu) <> .Cells(r1, Colu) Then
If .Cells(r1, Colu) <> "" Then .Range(.Cells(r1, Colu), .Cells(r - 1, Colu)).Merge
.Cells(r1, Colu).VerticalAlignment = xlCenter
r1 = r
ElseIf r = p + pY - 1 And r <> r1 Then
.Cells(r, Colu) = ""
.Range(.Cells(r1, Colu), .Cells(r, Colu)).Merge
.Cells(r1, Colu).VerticalAlignment = xlCenter
Else
.Cells(r, Colu) = ""
If .Cells(r + 1, 1) = "" Then
.Range(.Cells(r1, Colu), .Cells(r, Colu)).Merge
.Cells(r1, Colu).VerticalAlignment = xlCenter
End If
End If
Next r
Next Colu
If .Cells(r, 1) = "" Then Exit For
Next p
End If
.PrintOut

End With
Screen.MousePointer = vbDefault
End Sub
csdncb 2002-11-22
  • 打赏
  • 举报
回复
在导出时可以处理数据啊!
或者在报表中用sum,group(分组字段)处理数据!
listworld 2002-11-22
  • 打赏
  • 举报
回复
你可以到这的论坛->vba讨论区看看呀

809

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧