Skip to content

Instantly share code, notes, and snippets.

@mjsqu
Created December 4, 2023 18:52
Show Gist options
  • Save mjsqu/cb4424286ff5b7008dc4b4b19da8629c to your computer and use it in GitHub Desktop.
Save mjsqu/cb4424286ff5b7008dc4b4b19da8629c to your computer and use it in GitHub Desktop.
Select a range of cells in Excel - creates shapes containing the text in the cells
Sub CreateShapes()
i = 0
For Each cell In Selection
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, i * 20, i * 20, 72, 20)
With shp.TextFrame2
.VerticalAnchor = msoAnchorMiddle
.TextRange.ParagraphFormat.Alignment = msoAlignCenter
.AutoSize = msoAutoSizeShapeToFitText
.WordWrap = msoFalse
.TextRange.Characters.Text = cell.Value
End With
i = i + 1
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment