Hello all!
I'm hoping for some help in altering the below code to insert a text box below the shape as it is inserted. Realize a sample workbook is probably more helpful but I'm not sure how/if I can attach one. Thoughts on a way ahead would be appreciated!
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub Testing()
'Calls the Named Ranges needed for the code to run
Dim myCell As Range
Dim mySel As Range
'Sets dimension to center pictures within cell
Dim myR As Range
Dim myP As Shape
Set mySel = Selection
With Application
.ScreenUpdating = False
Rows("4:4").EntireRow.Hidden = False
'Checks first to see if a cell within the named range is blank, skips if it is, and calls the appropriate image if not
On Error Resume Next
For Each myCell In Range("KeyCells")
If myCell <> "" Then
'Deletes old image and replaces it with the called new one
ActiveSheet.Shapes(myCell.Address & "Final").Delete
ActiveSheet.Shapes(myCell.Value).Select
Selection.Copy
myCell.Offset(0, 0).Select
ActiveSheet.Paste
Selection.Name = myCell.Address & "Final"
Selection.ShapeRange.ZOrder msoSendToBack
Selection.AddTextbox(msoTextOrientationHorizontal, 2.5, 1.5, 116, 145).TextFrame.Characters.Text = "Test"
'Centers pictures within cell
With Selection
Set myR = .TopLeftCell
.Left = myR.Left + (myR.Width - .Width) / 2
.Top = myR.Top + (myR.Height - .Height) / 2
End With
Else: ActiveSheet.Shapes(myCell.Address & "Final").Delete
GoTo Skip
End If
Skip:
Next myCell
mySel.Select
Rows("4:4").EntireRow.Hidden = True
.ScreenUpdating = True
End With
End Sub
</code>
I'm hoping for some help in altering the below code to insert a text box below the shape as it is inserted. Realize a sample workbook is probably more helpful but I'm not sure how/if I can attach one. Thoughts on a way ahead would be appreciated!
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub Testing()
'Calls the Named Ranges needed for the code to run
Dim myCell As Range
Dim mySel As Range
'Sets dimension to center pictures within cell
Dim myR As Range
Dim myP As Shape
Set mySel = Selection
With Application
.ScreenUpdating = False
Rows("4:4").EntireRow.Hidden = False
'Checks first to see if a cell within the named range is blank, skips if it is, and calls the appropriate image if not
On Error Resume Next
For Each myCell In Range("KeyCells")
If myCell <> "" Then
'Deletes old image and replaces it with the called new one
ActiveSheet.Shapes(myCell.Address & "Final").Delete
ActiveSheet.Shapes(myCell.Value).Select
Selection.Copy
myCell.Offset(0, 0).Select
ActiveSheet.Paste
Selection.Name = myCell.Address & "Final"
Selection.ShapeRange.ZOrder msoSendToBack
Selection.AddTextbox(msoTextOrientationHorizontal, 2.5, 1.5, 116, 145).TextFrame.Characters.Text = "Test"
'Centers pictures within cell
With Selection
Set myR = .TopLeftCell
.Left = myR.Left + (myR.Width - .Width) / 2
.Top = myR.Top + (myR.Height - .Height) / 2
End With
Else: ActiveSheet.Shapes(myCell.Address & "Final").Delete
GoTo Skip
End If
Skip:
Next myCell
mySel.Select
Rows("4:4").EntireRow.Hidden = True
.ScreenUpdating = True
End With
End Sub
</code>