全シート

全シートに対して処理を実行
本文sub 全シートに対して処理を実行()

dim 全シートas worksheet

for each 全シート in worksheets

全シート.tab.colorindex=xlcolorindexnone
next

end sub

行を一行おきに挿入

行を一行おきに挿入
sub 行を一行おきに挿入()
range(“a3″).select
do until activecell.value=””

activecell.offset(1).entirerow.insert
activecell.offset(2).select
loop
end sub

繰り返し

sub 繰り返し()

dim 数as nteger
for 数=1to 3

worksheets.add before:worksheets(数)
activesheets.name=”追加” &数

next 数
end sub

条件分岐3

sub 条件分岐 ()

select case range(“b4”).value
case Is >=50
activesheet.tab.colorindex=11
case Is >=40
activesheet.tab.colorindex=5
case Is >=30
activesheet.tab.colorindex=33
case Is >=20
activesheet.tab.colorindex=37
case Is >=10
activesheet.tab.colorindex=34
case else
activesheet.tab.colorindex=3
end select

end sub

複数分岐

sub 複数分岐()

if range(“b4″).value=”” then
activesheet.tab.colorindex=3

elseif range(“b4”).value>=40 then
activesheet.tab.colorindex=5

elseif range(“b4”).value>=30 then
activesheet.tab.colorindex=37

else

activesheet.tab.colorindex=xlcolorindexnone

end if

end sub

ブックの保存

Sub ブックの保存()

workbooks.add
range(“A1″).value=”練習”

ActiveWorkbook.saveAs_
filename:=”保存練習1.xlsx”
end sub