Consulting

Results 1 to 4 of 4

Thread: Load database values into Worksheet

  1. #1
    VBAX Regular
    Joined
    Nov 2007
    Posts
    19
    Location

    Load database values into Worksheet

    Hi,

    Can anybody tell me the best method to load or set values on my worksheet using VBA when I open the worksheet from scratch?

    I have tried all sorts of initialisation but as I havent been working with VBA for a while I have not been able to do so. Im sure its simple but struggling on this one.

    Many thanks in advance

    JimFl78

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Can you give us an example of how you want the data laid out on the sheet and where is the data currently stored?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Regular
    Joined
    Nov 2007
    Posts
    19
    Location
    At the moment I currently have a button that will load my database values into the worksheet. I have no porblem connecting to my database and retrieving and placing the values in the relevant cells.

    However I would like the function to automatically load this when the excel sheet is first loaded. I am not sure how to do this.

    Elements of my project

    Sheet 1
    Module - this contains the events for my button click. I will need to place this code on the event like worksheet_load. However I have tried this without any luck. The problem is that I am trying to find the event that I can use to trigger the load once the project is opened and where this event code will exist in my project. Ie in the Sheet1 code or the module code ?

    I hope this helps to clarify a bit more what I am trying to achieve.

  4. #4
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    Worksheet-level events don't trigger when a workbook opens. You need to use a Workbook-level event.

    Use the "Workbook_Open" event; put it in the "ThisWorkbook" code pane.


    [vba]Private Sub Workbook_Open()[/vba]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •