|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
已经得到高手的帮助,他帮我解决了合并输出的问题,还有在VBA中要设置指定哪些(最多20个要参加合并计算的工作表,第个工作表的名称不相同)工作表的问题还需要解决。请大侠们帮忙。他的代码如下:
Option Explicit
Private Function IsFD(fn As String) As Integer
On Error Resume Next
If Dir(fn, vbNormal Or vbHidden Or vbReadOnly Or vbSystem Or vbArchive) = "" Then
If Dir(fn, vbNormal Or vbHidden Or vbReadOnly Or vbSystem Or vbArchive Or vbDirectory) = "" Then IsFD = 0 Else IsFD = 2
Else
IsFD = 1
End If
End Function
Private Function IsDocOpened(ByRef Doc As Object) As Boolean
On Error Resume Next
IsDocOpened = False
IsDocOpened = Doc.Windows(1).Visible
End Function
Private Sub CommandButton2_BeforeDragOver(ByVal Cancel As MSForms.ReturnBoolean, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal DragState As MSForms.fmDragState, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)
End Sub
Private Sub CommandButton2_BeforeDropOrPaste(ByVal Cancel As MSForms.ReturnBoolean, ByVal Action As MSForms.fmAction, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)
End Sub
Private Sub CommandButton2_Click()
Dim i, aa, c, s, s_name, xx, xxx, t_name
t_name = Replace(ThisWorkbook.Name, "xls", "txt")
Open t_name For Output As #1
c = Worksheets.Count '工作表的个数
For s = 1 To c
s_name = Worksheets(s).Name
xx = Worksheets(s_name).Cells(458, 14).Value
xxx = Worksheets(s_name).Cells(459, 14).Value
For i = xx To xxx
aa = Worksheets(s_name).Cells(i, 14).Value
Print #1, aa;
Next i
Print #1, Chr$(13)
Next s
Close #1
End Sub
Private Sub CommandButton2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
End Sub
Private Sub CommandButton2_Error(ByVal Number As Integer, ByVal Description As MSForms.ReturnString, ByVal SCode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, ByVal CancelDisplay As MSForms.ReturnBoolean)
[ 本帖最后由 刘泽海 于 2009-10-10 00:29 编辑 ] |
|