急求高手解决:处理合并单元格问题!!!急急急
比如,有一个占有6列(A1:A6)的合并单元格,在vba代码中我录制宏的时候我想选中一行,比如就第一行,生成的代码是Rows(1).select。但是我用代码实现选中一行的时候我用Rows(1).select时候,我调试过程中发现他选中的是6行。就是他选择的时候是按照合并单元格最大占有行数来选中,问题我现在清楚,因为合并单元格的原因。
跪求高手帮我解决代码实现选中一行(这一行是合并单元格的第一行),急!急!
[解决办法]
http://download.csdn.net/detail/veron_04/1627060
[解决办法]
高手,现在不是这个看这个编程规范的问题,这我有书。能提供解决方案吗?谢谢
[解决办法]
MARK!!
[解决办法]
3楼的 能详细点吗?谢谢,急死了
[解决办法]
Option Explicit
Private xlsApp As Excel.Application 'Excel应用对象
Private xlsBook As Excel.Workbook 'Excel工作薄对象
Private xlsSheet As Excel.Worksheet 'Excel工作表对象
Private Sub Command1_Click()
xlsApp.Range("B3:C3").Select
With xlsApp.Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
xlsApp.Selection.Merge
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:打开指定的Excel文件
'参数说明:xlsAPP:Excel应用对象
' :xlsWork:Excel工作薄对象
' :xlsSheet:Excel工作表对象
' :strExcelFile:Excel文件路径
' :strSheetName:工作表名
' :strPWD:密码
' :bolVisible:表的可见性
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Private Function funOpenExcelFile(ByRef xlsApp As Excel.Application, _
ByRef xlsWork As Excel.Workbook, _
ByRef xlsSheet As Excel.Worksheet, _
ByVal strExcelFile As String, _
ByVal strSheetName As String, _
ByVal strPWD As String, _
ByVal bolVisible As Boolean) As Boolean
On Error GoTo errFun
funOpenExcelFile = False
Set xlsApp = CreateObject("Excel.Application")
Set xlsWork = xlsApp.Workbooks.Open(strExcelFile, , False, , strPWD, strPWD)
Set xlsSheet = xlsBook.Worksheets(strSheetName)
xlsSheet.Activate
xlsApp.Visible = bolVisible
funOpenExcelFile = True
Exit Function
errFun:
funOpenExcelFile = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:关闭指定的Excel文件
'参数说明:xlsAPP:Excel应用对象
' :xlsWork:Excel工作薄对象
' :xlsSheet:Excel工作表对象
' :bolSave:是否保存
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Private Function funCloseExcelFile(ByRef xlsApp As Excel.Application, _
ByRef xlsWork As Excel.Workbook, _
ByRef xlsSheet As Excel.Worksheet, _
ByVal bolSave As Boolean) As Boolean
On Error GoTo errFun
If bolSave Then xlsBook.Save
Set xlsSheet = Nothing
xlsBook.Close
Set xlsBook = Nothing
Set xlsApp = Nothing
funCloseExcelFile = True
Exit Function
errFun:
funCloseExcelFile = False
End Function
Private Sub Form_Load()
Dim bolP As Boolean
'打开Excel文件
bolP = funOpenExcelFile(xlsApp, xlsBook, xlsSheet, App.Path & "\111.xls", "Sheet1", "", True)
End Sub
[解决办法]
问题我自己已经解决,谢谢各位的参与。后续还有新问题。。。