|
エラー処理に関するWeb とっても役に立ちました ありがとうございました♪ '------------------------------------------------------------------------- Option Explicit Private Sub CommandButton1_Click()
'Dim Wb1 As Workbook
Err:Dim Wb1Sh1 As Worksheet 'Dim CSVWb1 As Workbook Dim CSVWb1Sh1 As Worksheet Dim MaxRow As Integer Dim S As String 'Set Wb1 = ActiveWorkbook Set Wb1Sh1 = ActiveWorkbook.Worksheets("sheet1" ![]() S = Wb1Sh1.Range("I7" ![]() On Error GoTo Err Workbooks.Open "C:\Users\*****\Desktop\" & S & ".CSV" 'Set CSVWb1 = ActiveWorkbook Set CSVWb1Sh1 = ActiveWorkbook.Worksheets(1) MaxRow = CSVWb1Sh1.Cells(Rows.Count, 1).End(xlUp).Row CSVWb1Sh1.Range(CSVWb1Sh1.Cells(1, 1), CSVWb1Sh1.Cells(MaxRow, 3)).Select Wb1Sh1.Range("A4" .PasteSpecial Paste:=xlPasteValues, Operation:=xlNoneApplication.DisplayAlerts = False 'CSVWb1Sh1.Save CSVWb1Sh1.Close Application.DisplayAlerts = True Set Wb1 = Nothing Set Wb1Sh1 = Nothing Set CSVWb1 = Nothing Set CSVWb1Sh1 = Nothing End Sub '-------------------------------------------------------------------------
|

- >
- Yahoo!サービス
- >
- Yahoo!ブログ
- >
- 練習用






