Excel VBA質問箱 IV

当質問箱は、有志のボランティア精神のおかげで成り立っています。
問題が解決したら、必ずお礼をしましょうね。
本サイトの基本方針をまとめました。こちら をご一読ください。

投稿種別の選択が必要です。ご注意ください。
迷惑投稿防止のため、URLの入力を制限しています。ご了承ください。


41926 / 76735 ←次へ | 前へ→

【39883】Re:CSVファイルを読み込むやり方(ソース)
質問  エクセルホーリー  - 06/7/3(月) 15:48 -

引用なし
パスワード
   <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
0 hits

【39882】CSVファイルを読み込むやり方 エクセルホーリー 06/7/3(月) 15:42 質問
【39883】Re:CSVファイルを読み込むやり方(ソース) エクセルホーリー 06/7/3(月) 15:48 質問
【39884】Re:CSVファイルを読み込むやり方(ソース) エクセルホーリー 06/7/3(月) 15:50 質問
【39885】Re:CSVファイルを読み込むやり方(ソース) エクセルホーリー 06/7/3(月) 15:51 質問
【39886】Re:CSVファイルを読み込むやり方(ソース) エクセルホーリー 06/7/3(月) 15:51 質問
【39900】Re:CSVファイルを読み込むやり方(ソース... 漂流民 06/7/4(火) 1:18 発言
【39907】Re:CSVファイルを読み込むやり方(ソース... エクセルホーリー 06/7/4(火) 9:22 質問
【39911】Re:CSVファイルを読み込むやり方(ソース... neptune 06/7/4(火) 9:40 回答
【39912】Re:CSVファイルを読み込むやり方(ソース... エクセルホーリー 06/7/4(火) 10:21 お礼

41926 / 76735 ←次へ | 前へ→
ページ:  ┃  記事番号:
2610219
(SS)C-BOARD v3.8 is Free