0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

メモ

Posted at
Option Explicit

Sub readSheet()
    Dim wb As Workbook
    Dim settingWs As Worksheet
    Dim kind As String
    Dim lastRow As Long
    Dim lastCol As Long
    Dim outputNum As Long
    Dim oCount As Long
    
    Set wb = ThisWorkbook
    
    Set settingWs = wb.Sheets("テスト")
    
    lastRow = settingWs.Cells(settingWs.Rows.Count, 1).End(xlToLeft).Row
    lastCol = settingWs.Cells(settingWs.Columns.Count, 1).End(xlToLeft).Column
    oCount = 0
    
    Dim i As Long
    Dim j As Long
    
    
    For i = 1 To lastRow Step 2
        oCount = oCount + 1
        
        For j = 1 To lastCol
            kind = settingWs.Cells(i, j)
            outputNum = settingWs.Cells(i + 1, j)
            OutputData kind, outputNum, oCount
         Next j
    Next i
    
End Sub


Sub OutputData(kind As String, outputRowCount As Long, colCount As Long)
    Dim wb As Workbook
    Dim outputWs As Worksheet
    Dim lastRow As Long
    Dim outputNum As String
    
    Set wb = ThisWorkbook
    Set outputWs = wb.Sheets("output")
    
    lastRow = outputWs.Cells(1, colCount).End(xlToLeft).Row
    
    
    Select Case True
        Case kind Like "待機*"
            outputNum = "0"
        Case kind Like "走行*"
            outputNum = "1"
        Case kind Like "急速充電*"
            outputNum = "2"
        Case kind = "200V充電"
            outputNum = "3"
        Case kind = "冷却"
            outputNum = "4"
    End Select
    
    Dim i As Long
    For i = 1 To outputRowCount
        outputWs.Cells(lastRow, colCount) = outputNum
        lastRow = lastRow + 1
    Next i
    
    
        
End Sub

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?