条件分岐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

5ずつ増加する値を埋め込む

Sub Macro0510()
Range(“B2”).Value = 1
Range(“B3”).Value = 6
Range(“B2:B3”).AutoFill Destination:=Range(“B2:B8”)
End Sub


Sub Macro0511()
Range(“B2”).Value = 1
Range(“B2:B8”).DataSeries Step:=5
End Sub