Refresh on VBA

trsisko

Board Regular
Joined
May 20, 2008
Messages
176
Can anyone confirm if Refresh works for VBA or if I can use something similar?


Me.Label2.Refresh
Me.Label2.Width = 361.1 * (m_QID / m_TotalUniqueQuestions)
Me.Label2.Caption = Format((m_QID / m_TotalUniqueQuestions), "0.0%")
Me.lblQID.Caption = m_QID
Me.lblQuestion.Caption = m_Question
Me.LblDesc.Caption = strQInfo(2)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Depends what you want a command such as Refresh to do - you can Repaint a userform, but neither a label nor a Userform have a Refresh property/method.
 
Upvote 0
Heres the code, Baiscally its a progress bar. Prior to this bar I copy a sheet to the use the code. The control label2 doesnt update the progress bar length according to the new sheet.

Code:
    'Load Controls with Data
    Me.Label2.Width = 361.1 * (m_QID / m_TotalUniqueQuestions)
    Me.Label2.Caption = Format((m_QID / m_TotalUniqueQuestions), "0.0%")
    Me.lblQID.Caption = m_QID
    Me.lblQuestion.Caption = m_Question
    Me.LblDesc.Caption = strQInfo(2)
 
Upvote 0
I've updated the code with something I found in Google. Looks like if I change the Label properties to Visible then not visible in may update. I'll unit test this and see if it works.


Code:
'Load Controls with Data
Dim n As Long
For n = 1 To 10
Label2.Visible = Not Label2.Visible
DoEvents
Me.Label2.Width = 361.1 * (m_QID / m_TotalUniqueQuestions)
Me.Label2.Caption = Format((m_QID / m_TotalUniqueQuestions), "0.0%")
Me.lblQID.Caption = m_QID
Me.lblQuestion.Caption = m_Question
Me.LblDesc.Caption = strQInfo(2)
Next n
 
Upvote 0
Didn't seem to work as expected. How would I define the repaint method?

label2.repaint?
 
Upvote 0
No, as I said it is a method of the Userform, so you would run your process (ie update the label size) then call the Repaint method of the Userform:

Rich (BB code):
Me.Label2.Width = 361.1 * (m_QID / m_TotalUniqueQuestions)
Me.Label2.Caption = Format((m_QID / m_TotalUniqueQuestions), "0.0%")
Me.lblQID.Caption = m_QID
Me.lblQuestion.Caption = m_Question
Me.LblDesc.Caption = strQInfo(2)
Me.Repaint


Note that you must have these controls on a userform for this to work (a worksheet has no Repaint method).
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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