EXCEL VBA 另存新档的问题

Home Home
引用 | 编辑 jay927
2006-03-10 17:02
楼主
推文 x0
1.请问要怎样让运算完成的EXCEL报表直接自动另存新档?
2 ..

访客只能看到部份内容,免费 加入会员



献花 x0
引用 | 编辑 circlemap
2006-03-10 17:44
1楼
  
Option Explicit
Const FolderPath As String = "C:\tmp\"


Sub eee()

Dim strDay As String
Dim strMonth As String
Dim strYear As String

strDay = Day(Now)
strMonth = Month(Now)
strYear = Year(Now)

If Val(strDay) < 10 Then
strDay = "0" & strDay
End If

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

strYear = Right(strYear, 2)


Application.DisplayAlerts = False

ThisWorkbook.SaveAs (FolderPath & strDay & strMonth & strYear)

Application.DisplayAlerts = True

End Sub

稍微写了一下   不过 你要有 C:\tmp\ 这个资料夹存在,或者你改
Const FolderPath As String = "C:\tmp\" 这一句成为你要的资料夹

献花 x0
引用 | 编辑 jay927
2006-03-11 00:49
2楼
  
感谢大大!
存档的部分完成了!
不过另外的问题又出现!
新存的档案连巨集也一起存进去里面!
能够做到新存的档案里面只有资料,不把巨集也存进去吗?

献花 x0
引用 | 编辑 iwinblue
2009-04-23 18:51
3楼
  
请问依下这个地方哪里有错,我看不出来,请大家帮我依下,感恩
储存的档案,叫不出来
以下所以的条件
排序,再另存新档

Option Explicit
Const FolderPath As String = "C:\tmp\"
Sub eee()

  Cells.Select
  Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("B2") _
    , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
    False, Orientation:=xlTopToBottom, SortMethod:=xlStroke, DataOption1:= _
    xlSortNormal, DataOption2:=xlSortNormal
  Range("H7").Select
  Columns("I:I").ColumnWidth = 11.75
  Columns("I:I").ColumnWidth = 14






Dim strYear As String
Dim strMonth As String
Dim strDay As String

strYear = Year(Now)
strMonth = Month(Now)
strDay = Day(Now)

strYear = Right(strYear, 2)

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

If Val(strDay) < 10 Then
strDay = "0" & strDay
End If


Application.DisplayAlerts = False

ThisWorkbook.SaveAs (FolderPath & strYear & strMonth & strDay)

Application.DisplayAlerts = True

End Sub

献花 x0
引用 | 编辑 lmz
2009-06-06 00:08
4楼
  
用巨集录制如下
  Cells.Select
  Selection.Sort Key1:=Range("C2")、Order1:=xlAscending、Key2:=Range("B2") _
    、Order2:=xlAscending、Header:=xlYes、OrderCustom:=1、MatchCase:=False _
    、Orientation:=xlTopToBottom、SortMethod:=xlPinYin、DataOption1:= _
    xlSortNormal、DataOption2:=xlSortNormal
.
.
Columns("I:I").ColumnWidth = 11.75......此段可以删除
Columns("I:I").ColumnWidth = 14

If Val(strMonth) < 10 Then
strMonth = "0" & strMonth
End If

可以改为

strMonth = WorksheetFunction.Text(strMonth, "00")

献花 x0