用宏录下你需要的动作啊
然后结合OFFICE光盘里的VBA帮助看看,调调就可以了
================================================================
举杯邀明月
然后结合OFFICE光盘里的VBA帮助看看,调调就可以了
================================================================
举杯邀明月
解决方案 »
- 关于vb读写文本文档
- VB6抽疯问题,,
- vb动态建立Access,新建库名已存在时的问题,路过的高人指点下
- 求mstop的关于flexgrid的一系列精华贴链接
- 在VB中如何把一个对像,如结果集(recorderset) 做为参数传递给函数进行处理??????
- 出售西门子手机短信系统源程序,功能强大!!!!!
- 请问谁有VB编的串口通讯源码,要含有CRC8检验,急用!
- Win2000环境下,VB程序如何能得到计算机当前的CPU使用率?
- 如何用VB做股票数据接收系的源代码?
- picture和image?
- 菜鸟请教大家一个问题;addoc的翻页和查询还有添加的功能该怎么实现啊
- 非常简单的api函数问题~~~
'将列数据转换成(1) 字符(A)
Public Function GetCellName(Col As Long) As String
If Col < 27 Then
GetCellName = Chr(Col + 64) Else
GetCellName = Chr(Int((Col - 1) / 26) + 64) & Chr(((Col - 1) Mod 26) + 65)
End If
End Function'合并单元
Public Sub CellMerge(ExSheet As Excel.Worksheet, rStart As Long, cStart As Long, rEnd As Long, cEnd As Long)
Dim Slt As String
Slt = GetCellName(cStart) & CStr(rStart) & ":" & GetCellName(cEnd) & CStr(rEnd)
With ExSheet
.Range(Slt).Select
With .Application.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
End With
.Application.Selection.Merge
End With
End Sub
’将单元设置成 数字
Public Sub CellNumber(ExSheet As Excel.Worksheet, rStart As Long, cStart As Long, rEnd As Long, cEnd As Long,Lng as long)
Slt = GetCellName(cStart) & CStr(rStart) & ":" & GetCellName(cEnd) & CStr(rEnd)
With ExSheet
.Range(Slt).Select
slt=mid("0.0000000000",1,2+lng)
.Application.Selection.NumberFormatLocal = slt With .Application.Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
End With
End With
End Sub
'将单元设置成字符格式
Public Sub CellChar(ExSheet As Excel.Worksheet, rStart As Long, cStart As Long, rEnd As Long, cEnd As Long)
Slt = GetCellName(cStart) & CStr(rStart) & ":" & GetCellName(cEnd) & CStr(rEnd)
With ExSheet
.Range(Slt).Select
.Application.Selection.NumberFormatLocal = "@"
With .Application.Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
End With
End With
End Sub’单元化线
Public Sub CellLine(ExSheet As Excel.Worksheet, rStart As Long, cStart As Long, rEnd As Long, cEnd As Long)
Slt = GetCellName(cStart) & CStr(rStart) & ":" & GetCellName(cEnd) & CStr(rEnd)
With ExSheet
.Range(Slt).Select
.Application.Selection.Borders(xlDiagonalDown).LineStyle = xlNone
.Application.Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With .Application.Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Application.Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Application.Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Application.Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Application.Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Application.Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub
’追加新sheet并命名
Public Sub GetExSheet(ExBook As Excel.Workbook, ExSheet As Excel.Worksheet, cName As String, iCount As Long)
With ExSheet
If iCount <= .Application.Sheets.Count - 1 Then
.Application.Sheets(iCount).Select
.Application.Sheets(iCount).Name = cName
Else
.Application.Sheets(ExSheet.Application.Sheets.Count).Select
.Application.Sheets.Add
.Application.Sheets(ExSheet.Application.Sheets.Count - 1).Select
.Application.Sheets(ExSheet.Application.Sheets.Count - 1).Name = cName
End If
End With
End Sub希望对你有帮助 。。
象楼上说的那样 看看 VBA 那个东东 很优秀的哦
举杯邀明月