Refreshing Query with UserForm

Yuriy B

New Member
Joined
Feb 4, 2015
Messages
26
Hi,

I have a UserForm with text boxes. When data is typed into a textbox, it is inserted into a cell on "Cost Analysis Tab" with this code:

Private Sub TextBox4_AfterUpdate()
Worksheets("Cost Analysis").Range("A1").Value = UCase(TextBox4.Value)
End Sub

I have a Connection Name: "Query from RBIT_vmfg" That looks at A1 on "Cost Analysis" tab.

The query refreshes as soon as I close the UserForm, but i would like it to refresh after the information has been entered into A1.

I have tried:
Sheets("Cost Analysis").Select
ThisWorkbook.RefreshAll

ActiveWorkbook.RefreshAll
DoEvents

Nothing has worked for me. Please let me know if there is a way that the query can refresh/update once the information has been put into TextBox4 or cell A1 in Cost Analysis tab.

Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
In the ThisWorkbook object

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
   If Not Intersect(Worksheets("Cost Analysis").Range("A1"), Target) Is Nothing Then
      ThisWorkbook.RefreshAll
   End If
End Sub
 
Last edited:
Upvote 0
No, nothing changed.
As long as the Userform is open, the Query table doesn't update.
As soon as I close the UserForm, The Query table updates with the correct info.
 
Upvote 0
Yuriy,

How are you calling your userform? (Modal/Modeless)

Try:
Code:
UserForm1.Show False    ' Or you can use vbModeless or 0
 
Upvote 0
I have a button on one of the Tabs that opens the userForm.
The Code for the userForm:

Sub OpenInsert()


UserForm1.Show
UserForm1.TextBox1.SetFocus


End Sub


I changed it and the table updated!!!!:

Sub OpenInsert()


UserForm1.Show False
UserForm1.TextBox1.SetFocus


End Sub


Thanks to all :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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