2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

景気ウォッチャー調査の景気判断理由集をエクセルで綺麗にする

Last updated at Posted at 2019-09-07

##このマクロを実行するとこうなります
実行前
image.png
実行後
image.png

##コード
vba初心者の方は
https://www.officepro.jp/excelvba/ini/
こちらで「プラグラムの記述と実行」まで学んでください(五分で出来るので安心してね)
後は下のコードをコピーしてコードウインドウに張り付け、
macroというマクロを実行してください。

Function location(vaf As Range) As String
    Dim name As String
    Dim n As Long
    name = vaf.Value
    n = InStr(name, "(")
    name = Mid(name, n + 1)
    n = InStr(name, ")")
    location = Left(name, n - 1)
End Function

Sub macro()
    Dim i, j As Long
    Dim location_name, kind_name As String
    j = 0
    Columns(1).Insert
    For i = 1 To 10000
        If j > 10 Then
            Exit For
        End If
        If Cells(i, 5) = "" Or Cells(i, 5) = "業種・職種" Then
            Rows(i).Delete
            i = i - 1
            j = j + 1
        Else
            j = 0
            If Cells(i, 2) <> "" Then
                location_name = location(Cells(i, 2))
                kind_name = Left(Cells(i, 2), 2)
            End If
            Cells(i, 1) = location_name
            Cells(i, 2) = kind_name
        End If
    Next i
End Sub

###解説は後日書きます・・・
qiita初投稿なんです。許して下さい・・・

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?