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?

More than 5 years have passed since last update.

セルに設定した値をシェルスクリプトなどのファイルとして出力

0
Last updated at Posted at 2019-12-16

作業をする際にエクセルのリストをもとにシェルスクリプトを作成することが増えたため作成してみました。
以下はサンプルなので、1文字列+1エリア分しかありません。

※このままだと改行コードがLFで出力されるので、注意してください。
CR+LFにしたい場合は別の記述を追加する必要があります。

Sub makeShell()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheet(1)

Dim datFile As String

datFile As String
Open datFile For Output As #1
Dim i As Long

‘エリア1
i = 0

‘エリア1開始まで 固定文字列を設定するなど
Print #1, ws.Cells(4,1)

‘エリア1
Do While ws.Cells(i + 18,2).Value<>””

Print #1,ws.Cells(i + 18,13).Value
i = i +i
Loop

‘以下必要に応じて記述を追加
‘たとえばエリア2として(i + 18,14)を対象にするなど

Close #1

MsgBox “XXXX 作成完了”
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?