+ Reply to Thread
Results 1 to 2 of 2

Can I use a defined integer as part of a shape name

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Can I use a defined integer as part of a shape name

    I am fairly new at macros and still learning syntax for different scenarios.

    In my workbook cell A1 is defined as an integer
        Dim trialcounter As Integer
        trialcounter = Range("A1").Value
    there is a button that a user clicks and after every click, the trial counter is advanced by 1

        Range("A1").Value = trialcounter + 1
    What I would like to do is have five new shapes appear each time the user clicks the button. There is a single button and it needs to unhide the new shapes to the next row. (The circles would be there, hidden, and then when the user hits the button, the next five would appear and so on).

    Right now the code looks like this:
        ActiveSheet.Shapes("circle_1").Visible = True
        ActiveSheet.Shapes("circle_2").Visible = True
        ActiveSheet.Shapes("circle_3").Visible = True
        ActiveSheet.Shapes("circle_4").Visible = True
        ActiveSheet.Shapes("circle_5").Visible = True
    But I would like the code to be smart enough to continually advance the circles forward, as there is only one button, and not a new button for each line. and I only want five new buttons at a time, not for all of the buttons to appear on the first click.

    Is there a way to name the buttons "circle_trialcounter_1" to "circle_trialcounter_5" or something along those lines? I am really struggling with this problem and would appreciate any help!
    Last edited by newatmacros; 11-23-2010 at 07:30 PM. Reason: fixing post to match rules

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,987

    Re: Can I use a defined integer as part of a shape name

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Everyone who confuses correlation and causation ends up dead.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1