Shape not staying in position

Blobajob88

Board Regular
Joined
Mar 27, 2020
Messages
56
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I'm trying to develop a progress bar, which consists of a static rectangle with an internal rectangle that moves with time. I've set the width, height and left, top positions. It works fine for me on my big monitor and my laptop but when I get someone else to open it on their screen it shifts position. I've included what it looks like for me compared with someone else below, as well as a snippet of the code. Does anyone know what the issue is?

1731936917133.png


1731936954733.png



What happens on someone else's screen

1731937114041.png


VBA Code:
Sub CycleProgression2()



If ThisWorkbook.Sheets("Tunable Analyser").Range("AX5").Value = "Go" Then

ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Width = 20
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Height = 9
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Top = 135.5
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Left = 748.4933
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Rectangle 101").Top = 133.48
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Rectangle 101").Left = 747.6553

Application.OnTime Now + 0.00003, "CycleProgression3"

Else


    Call hideMessages.HideNonStopMeasurementMessages

End If


End Sub

Sub CycleProgression3()



If ThisWorkbook.Sheets("Tunable Analyser").Range("AX5").Value = "Go" Then

ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Width = 40
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Height = 9
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Top = 135.5
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Cycle Progression").Left = 748.4933
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Rectangle 101").Top = 133.48
ThisWorkbook.Sheets("Tunable Analyser").Shapes("Rectangle 101").Left = 747.6553


Application.OnTime Now + 0.00003, "CycleProgression4"

Else


    Call hideMessages.HideNonStopMeasurementMessages

End If


End Sub
 

Attachments

  • 1731937089135.png
    1731937089135.png
    11.4 KB · Views: 1

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hello,

I think it is related to the .Top property that can act very inconsistently with zoom level and screen size. If i were you i would put the rectangular bar in a cell, and use the cell's .Top and .Left properties to position my bar. You can also have the bar being the exact same size as the cell, and use some transparent borders if you want to make it look "inside" as you did.

By referring to a cell and not the worksheet, you should have more consistent results on shapes placement.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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