|
<CSVのデータ>
1,"AAA"
2,"BBB"
L,aaa,"あいうえお(0"シングル"/1"ツイン")",0
L,bbb,"かきくけこ(0"指定OFF"/1"指定ON")",1
L,ccc,"さしすせそ(0"指定OFF"/1"指定ON")",0
2,"CCC"
3,"DDD"
L,ddd,"たちつてと(m/inch)(0"m"/1"inch")",1
1の時 AAAは "B2" に書き込む
2の時 BBBは "C3" に書き込む
Lの時 aaaは "E5", "あいうえお(0"シングル"/1"ツイン")" "H5", 0 "AC5" に書き込む
Lの時 bbbは "E6", "かきくけこ(0"指定OFF"/1"指定ON")" "H6", 1 "AC6" に書き込む
Lの時 cccは "E7", "さしすせそ(0"指定OFF"/1"指定ON")", "H7", 0 "AC7" に書き込む
2の時,CCCは "C18" に書き込む
3の時,DDDは "D19" に書き込む
Lの時,dddは "E20" "たちつてと(m/inch)(0"m"/1"inch")" "H20", 1 AC20に書き込む
データがなくなるまで繰り返す
<マクロを組んだフォーマット>
Sub Macro1()
Dim count1 As Integer 'カウンター
Dim count2 As Integer 'カウンター
Dim count3 As Integer 'カウンター
'***********************************************************************
' 本来は無限ループ試験の為3回
'***********************************************************************
For count1 = 1 To 3
Application.Goto Reference:="Macro1"
Range("O4:O5").Select
Range("O5").Activate
ActiveWindow.SmallScroll Down:=-4
'*************************************************************************
' Format 作成
'*************************************************************************
For count2 = 1 To 2
'*************************************************************************
' ("B2:AF2") と ("B17:AF17")
'*************************************************************************
If count2 = 1 Then
Range(Cells(2 + 31 * (count1 - 1), "B"), Cells(2 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(17 + 31 * (count1 - 1), "B"), Cells(17 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'*************************************************************************
' ("C3:AF3") と ("C18:AF18")
'*************************************************************************
Selection.Borders(xlInsideVertical).LineStyle = xlNone
If count2 = 1 Then
Range(Cells(3 + 31 * (count1 - 1), "C"), Cells(3 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(18 + 31 * (count1 - 1), "C"), Cells(18 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'*************************************************************************
' ("D4:AF4") と ("D19:AF19")
'*************************************************************************
If count2 = 1 Then
Range(Cells(4 + 31 * (count1 - 1), "D"), Cells(4 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(19 + 31 * (count1 - 1), "D"), Cells(19 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'*************************************************************************
' ("E5:AF5") と ("E20:AF20")
'*************************************************************************
Selection.Borders(xlInsideVertical).LineStyle = xlNone
If count2 = 1 Then
Range(Cells(5 + 31 * (count1 - 1), "E"), Cells(5 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(20 + 31 * (count1 - 1), "E"), Cells(20 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'*************************************************************************
' ("E6:AF6") と ("E21:AF21")
'*************************************************************************
Selection.Borders(xlInsideVertical).LineStyle = xlNone
If count2 = 1 Then
Range(Cells(6 + 31 * (count1 - 1), "E"), Cells(6 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(21 + 31 * (count1 - 1), "E"), Cells(21 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'*************************************************************************
' ("E7:AF7") と ("E22:AF22")
'*************************************************************************
Selection.Borders(xlInsideVertical).LineStyle = xlNone
If count2 = 1 Then
Range(Cells(7 + 31 * (count1 - 1), "E"), Cells(7 + 31 * (count1 - 1), "AF")).Select
Else
Range(Cells(22 + 31 * (count1 - 1), "E"), Cells(22 + 31 * (count1 - 1), "AF")).Select
End If
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Sub
|
|