Excel VBA button keeps moving when clicked

Posted on 2007-07-25
Last Modified: 2008-01-09
I recorded a macro in excel to run a query.  Even though I checked "Save the password with the data" every time I select "Data:Refresh Data" it prompts for the password.  I want other people to be able to refresh the data without knowing the password so I put the password in the macro and loaded the code into the click event of a button I placed on the worksheet.  I set the data to start in A5 and put the button in B2.  Every time I click the button it correctly refreshes the data, but then moves the button to I2 which is off the screen making it look like the button has disappeared.  Is there any way to get it to stay put?
Question by:glennmgray
    LVL 15

    Expert Comment

    Are you inserting columns in your code? If columns are inserted after your code moves the button, this could be the problem.
    LVL 81

    Accepted Solution

    Right-click on the command button and select Format Control. Navigate to the Properties tab and select "Don't move or size with cells".


    Author Comment

    That worked, Thanks

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now