|
応援ありがとうございます
わずかながらずつ理解してきました
ここまで作ってみました
Option Explicit
Sub CommandButton1_Click()
月報読み込み.Hide
End Sub
Sub CommandButton2_Click()
Dim PASS1 As String
Dim YEAR1 As String
Dim MONTH1 As String
Dim DAY1 As String
Dim FILEPASS6 As String
Dim FILE6 As String
Dim i As Integer
Dim DayCount As String
Dim datDataDate As Date
Dim strFileName As String
PASS1 = TextBox5.Text
YEAR1 = TextBox1.Text
MONTH1 = TextBox2.Text
DAY1 = TextBox3.Text
DayCount = TextBox4.Text
On Error GoTo ERR:
datDataDate = CDate(YEAR1 & "/" & MONTH1 & "/" & DAY1)
For i = 1 To DayCount 'DayCountまでループ(日指定)
'ファイル名生成
strFileName = PASS1 & Format$(datDataDate, "yyyymmdd") & ".xls"
'CSV読込処理を記述
datDataDate = datDataDate + 1 '1日進む
Next i
ERR:
Const TITLE = "MsgBox"
MsgBox "エラ−が発生しました。" & Chr(13) & Chr(13) & "Error Number =" & ERR.Number & Chr(13) & "Error Message=" & ERR.Description, , TITLE
ActiveWindow.Close
月報読み込み.Hide
Exit_CommandButton2_Click:
End Sub
Sub UserForm_Activate()
TextBox5.Value = "D:\Data Folder\"
TextBox1.Value = "2004"
TextBox2.Value = "05"
TextBox3.Value = "01"
TextBox4.Value = "31"
End Sub
これで実行するとエラーで、終了します
'ファイル名生成
strFileName = PASS1 & Format$(datDataDate, "yyyymmdd") & ".xls"
やっぱり、ここの部分がわかりません (´;ェ;`)ウゥ・・・
|
|