VBA使用頻度の高いコード(12):セルに合わせてオブジェクト配置
セルに合わせてオブジェクト配置
セルに合わせてオブジェクト配置用コード
下のは矢印配置
===============================
Sub セルに合わせて矢印オブジェクト配置()
Range("X" & WorkID).Select
cellLenght = Selection.Width
cellHeight = Selection.Height
barSize = workTerm
barLenght = cellLenght * workTerm
barID = Range("E" & WorkID)
barHeight = 0
If WorkID = 9 Then
ActiveSheet.Shapes.AddShape(msoShapeLeftRightArrow, Cells(WorkID, barPosition).Left, Cells(WorkID, barPosition).Top + cellHeight * 0.75, barLenght, cellHeight * 0.1).Select
Else
ActiveSheet.Shapes.AddShape(msoShapeRightArrow, Cells(WorkID, barPosition).Left, Cells(WorkID, barPosition).Top + cellHeight * 0.4, barLenght, cellHeight * 0.3).Select
End If
With Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 255, 0)
.Line.ForeColor.RGB = RGB(255, 0, 0)
.Line.Weight = 0.5
.Name = "checkbar" & barID
End With
End Sub
===============================