Any way to deselect a select in VBA?

  • Re: Any way to deselect a select in VBA?


    Oh well. I will upload it but it probably won't tell you much. As I mentioned before all the data is pulled in to the file so it will probably have a bunch of REFs in it.


    ***Well it won't let me upload it. Gives a 500 error.

  • Re: Any way to deselect a select in VBA?


    Here's an example of my code working so that you can see it. Check the cells beforehand to see the formulas, then press the button. Check the cells afterwards and you will see there are no longer formulas, just values. There are also 2 hidden sheets - these sheets will also have the formulas replaced by values, feel free to check before and after.


    You can adapt this to see how it should work.


    ozgrid.com/forum/core/index.php?attachment/64671/

  • Re: Any way to deselect a select in VBA?


    That works awesome! Thanks for the work you have done and for putting up with me.


    However it changes some of my cell formats. The ones I set to accounting change to currency. Also I have a summary page that pulls from all the other pages. Well in my formulas on the other pages it may return "" so it will be blank, but on my summary page it reads that as a 0. I can probably change the formulas in my summary page to fix that, it was just an observation.


    Any ideas on these items?

  • Re: Any way to deselect a select in VBA?


    you can change the formatting of a range like so:


    Code
    1. Range("A1").NumberFormat = "0.00" '// Number
    2. Range("A1").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)" '// Accounting
    3. Range("A1").NumberFormat = "$#,##0.00" '// Currency
    4. Range("A1").NumberFormat = "@" '//Text


    Those are some examples that you can use to adapt your code. You could probably just use an =IF() formula to replace the 0 values with a blank string.

  • Your code

  • know this is old.. But if someone else needs an answer.


    Range.select gives a selection object.

    After you are done with it, you can recycle the selection object by

    selection.start =Selection.End


    That way selection object is deselected.

  • That may be true in Word, but it won't work in Excel, I'm afraid.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Ok. How about this? once the work is done, create a new range with a single cell and select it.


    Code
    1. Dim r as range
    2. Set r = ActiveSheet.Range("A1")
    3. r.Select
    4. Or in one line
    Code
    1. ActiveSheet.Range("A1").Select
  • Mert_in


    . Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.

    ['code]


    your code goes between these tags


    ['/code]


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Thanks.

  • Normally, if you want to deselect a cell or multiple cells from a selection, you just need to hold down the CTRL key and click on the cells you want to deselect. If you want to unselect a range of selected cells, you need to hold down the CTRL key and drag the range you want to deselect.



    Thanks

  • royUK

    Closed the thread.