|
Sub 実行()
Dim Filename As String
Dim r As Integer
Dim Fname As String
Filename = Application.GetOpenFilename
If Filename <> "False" Then
Filename = Replace(UCase(Filename), ".CSV", ".txt")
Workbooks.OpenText Filename:=Filename, DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Comma:=True, Fieldinfo:=Array(1, 2)
Else End
End If
Application.DisplayAlerts = False
Cells.Select
Selection.Copy
Workbooks.Add
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "集計"
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "TENZAIK(P)"
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "TENZAIK"
Worksheets("集計").Select
Cells(1, 1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Fname = Application.GetOpenFilename
If Fname <> "False" Then
Workbooks.OpenText Filename:=Fname, DataType:=xlDelimited, _
ConsecutiveDelimiter:=True, Comma:=True, Fieldinfo:=Array(1, 2)
Else: End
End If
Cells.Select
Selection.Copy
Workbooks("book1").Activate
Worksheets("TENZAIK").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Call TEN
End Sub
Sub TEN()
Dim 行 As Integer
Dim n As Integer
n = 2
行 = Columns(1).CurrentRegion.Rows.Count
Application.DisplayAlerts = False
Columns(2).Select
Selection.Insert
Cells(1, n).Value = "得意先"
Application.CutCopyMode = False
Cells(2, n).Select
Selection.FormulaR1C1 = "=MID(RC[-1],1,7)"
Selection.Copy
Range(Cells(3, n), Cells(行, n)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub
というコードがあるのですが、"=MID(RC[-1],1,7)"という計算式がうまく行きませんなぜでしょうか?
|
|