PDA

View Full Version : Set Adjust A Button Top Left Position Programmatically



jeffrey159
02-01-2013, 09:08 PM
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

Excel Fox
02-01-2013, 11:22 PM
So if you have 3 buttons (shapes) with names 1, 2 and 3,



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

jeffrey159
02-02-2013, 07:30 AM
erm, sorry what do i replace the SomeCondition with and must i replace the name SheetName to other thing??:confused:
what is the code to define WorkSheets, i tried googling but i can't find any except for macro stuff...

Excel Fox
02-02-2013, 10:34 AM
Some condition would be something like what you've mentioned in your original post.

The code would be something like



If Environ("USERNAME")="ExcelFox" OR Environ("USERNAME") = "Jeffrey" Then
'.....some code'
Else
'.....other code
End If

jeffrey159
02-02-2013, 12:46 PM
what about the WorkSheets what codes to define it??

Excel Fox
02-02-2013, 06:24 PM
In VBA, one normally refers to a worksheet by the name 'Sheet 1' with the code
Worksheets("Sheet 1")