Results 1 to 6 of 6

Thread: Set Adjust A Button Top Left Position Programmatically

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Set Adjust A Button Top Left Position Programmatically

    how do i do this coding If a button is not available for the current user then the next buttons must cover its space automatically.

    if i have 3 buttons, the middle one is not visible for current user, how do the next button cover its space??

    what's the code to do this

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    So if you have 3 buttons (shapes) with names 1, 2 and 3,

    Code:
    If SomeCondition = True Then
    Worksheets("SheetName").Shapes("1").Left = Worksheets("SheetName").Shapes("2").Left
    Worksheets("SheetName").Shapes("2").Visible = False
    Else
    Worksheets("SheetName").Shapes("1").Left = 10 ' Or whatever was the original left position
    Worksheets("SheetName").Shapes("2").Visible = True
    End If
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    erm, sorry what do i replace the SomeCondition with and must i replace the name SheetName to other thing??
    what is the code to define WorkSheets, i tried googling but i can't find any except for macro stuff...
    Last edited by Excel Fox; 02-02-2013 at 06:22 PM. Reason: Removed Quote

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Some condition would be something like what you've mentioned in your original post.

    The code would be something like

    Code:
    If Environ("USERNAME")="ExcelFox" OR Environ("USERNAME") = "Jeffrey" Then
    '.....some code'
    Else
    '.....other code
    End If
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    what about the WorkSheets what codes to define it??
    Last edited by Excel Fox; 02-02-2013 at 06:23 PM. Reason: Removed Quote

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    In VBA, one normally refers to a worksheet by the name 'Sheet 1' with the code
    Code:
    Worksheets("Sheet 1")
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 3
    Last Post: 06-01-2013, 11:31 AM
  2. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  3. Replies: 8
    Last Post: 08-05-2012, 10:07 AM
  4. Auto adjust for cells according to value using VBA
    By LalitPandey87 in forum Excel Help
    Replies: 3
    Last Post: 11-08-2011, 08:58 AM
  5. Replies: 2
    Last Post: 11-08-2011, 08:52 AM

Posting Permissions

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