Increment a series in a bubble

Flavien

Board Regular
Joined
Jan 8, 2023
Messages
70
Office Version
  1. 365
Platform
  1. Windows
Hello,

The code below allows me to insert an image (shape 8 point star) and write the letter "A" on it.
Would it be possible to change the code so that on the second click the letter "A" is replaced by "B" and so on? with the possibility of starting again at "A" if I wish?

Thanks a lot for your help!

Have a nice day :)

Rich (BB code):
Sub Keyence_220424()

    ActiveSheet.Shapes.AddShape(msoShape8pointStar, 400, 400, 28.35, 28.35).Select
    Selection.ShapeRange.Line.Visible = msoFalse

    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 255) 'pink
        .Transparency = 0
        .Solid
    End With

    Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle
        
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "A"
    
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1).ParagraphFormat
        .FirstLineIndent = 0
        .Alignment = msoAlignCenter

    End With
    
    With Selection.ShapeRange(1).TextFrame2.TextRange.Characters(1, 1).Font
        .Size = 14
    End With


End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
It works as follows:
  • To change the letter we need an available cell in your sheet, for example, cell Z1, adjust it in the macro.
  • Every time you run the macro, the letter will change to B, C and so on.
  • Note: The letter will change, but the position of the bubble on the sheet will always be the same.
  • To start again in A, simply delete the letter in cell Z1 or the one you have chosen and run the macro.

User the following macro.
VBA Code:
Sub Keyence_220424()
  Dim shp As Shape
  Dim cell As Range
 
  Set cell = Range("Z1")          'Fit to your cell
 
  If cell.Value = "" Then
    cell.Value = "A"
  ElseIf Asc(UCase(cell.Value)) = 90 Then
    cell.Value = "A"
  Else
    cell.Value = Chr(Asc(UCase(cell.Value)) + 1)
  End If
 
  Set shp = ActiveSheet.Shapes.AddShape(msoShape8pointStar, 400, 400, 28.35, 28.35)
  shp.Line.Visible = msoFalse

  With shp.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(255, 0, 255) 'pink
    .Transparency = 0
    .Solid
  End With

  With shp.TextFrame2.TextRange.Characters
    .Parent.VerticalAnchor = msoAnchorMiddle
    .Text = cell.Text
    .Font.Size = 14
    .ParagraphFormat.Alignment = msoAlignCenter
  End With
End Sub

🤗
 
Upvote 0

Forum statistics

Threads
1,223,157
Messages
6,170,420
Members
452,325
Latest member
BlahQz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top