Need a 'Refresh' button

  • Thread starter Thread starter cbrammer
  • Start date Start date
C

cbrammer

We are moving data from a database to Excel. We need the Excel spreadsheet to
update as we make changes in the database. What I need is to put a 'button'
on the spreadsheet that will refresh the data as we make changes in the
database. I know I need to code it in VB. Can anyone lead in me in a
direction? Thanks.
 
hi
you need to select a cell inside the query range.....
Private Sub CommandButton1_Click()
sheets("sheet1").activate
Range("A2").QueryTable.Refresh BackgroundQuery:=False
end sub

regards
FSt1
 
or more directly.....

Private Sub CommandButton1_Click()
With Sheets("Sheet1").Range("A2")
.QueryTable.Refresh BackgroundQuery:=False
End With
End Sub


--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top