+ Reply to Thread
Results 1 to 9 of 9

VB coding to clear a selection?

  1. #1
    StargateFan
    Guest

    VB coding to clear a selection?

    I currently have the selection clear by changing the cursor location
    to cell D2 (Range("D2").Select). So if the entire sheet had all the
    cells selected, this would clear the selection but would also move to
    another location. I actually need the active cell to remain the same
    as before the macro was invoked, but don't know the VB code for this.

    Thanks for any help in advance.


  2. #2
    CLR
    Guest

    Re: VB coding to clear a selection?

    Maybe.............

    Range("A1:A5").Select
    Selection.ClearContents


    Vaya con Dios,
    Chuck, CABGx3

    "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote in message
    news:[email protected]...
    > I currently have the selection clear by changing the cursor location
    > to cell D2 (Range("D2").Select). So if the entire sheet had all the
    > cells selected, this would clear the selection but would also move to
    > another location. I actually need the active cell to remain the same
    > as before the macro was invoked, but don't know the VB code for this.
    >
    > Thanks for any help in advance.
    >




  3. #3
    Bob Phillips
    Guest

    Re: VB coding to clear a selection?

    I think Chuck would mean

    Range("A1:A5").ClearContents

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "CLR" <[email protected]> wrote in message
    news:%[email protected]...
    > Maybe.............
    >
    > Range("A1:A5").Select
    > Selection.ClearContents
    >
    >
    > Vaya con Dios,
    > Chuck, CABGx3
    >
    > "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote in message
    > news:[email protected]...
    > > I currently have the selection clear by changing the cursor location
    > > to cell D2 (Range("D2").Select). So if the entire sheet had all the
    > > cells selected, this would clear the selection but would also move to
    > > another location. I actually need the active cell to remain the same
    > > as before the macro was invoked, but don't know the VB code for this.
    > >
    > > Thanks for any help in advance.
    > >

    >
    >




  4. #4
    Harald Staff
    Guest

    Re: VB coding to clear a selection?

    See also
    http://www.*****-blog.com/archives/2...-and-activate/
    for some theory.

    HTH. Best wishes Harald


    "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> skrev i melding
    news:[email protected]...
    > I currently have the selection clear by changing the cursor location
    > to cell D2 (Range("D2").Select). So if the entire sheet had all the
    > cells selected, this would clear the selection but would also move to
    > another location. I actually need the active cell to remain the same
    > as before the macro was invoked, but don't know the VB code for this.
    >
    > Thanks for any help in advance.
    >




  5. #5
    NC
    Guest

    Re: VB coding to clear a selection?

    hi stargatefan
    do you want clear the contents or just get rid of the selected
    cells(i.e.deactivating them) & again activate the cell on which you was
    working before.

    you can do this by using a temporary range which you can declare equal
    to your active cell(s) then run the macro & then again activating this
    temporary range.

    Regards
    NC


  6. #6
    StargateFan
    Guest

    Re: VB coding to clear a selection?

    On Sat, 29 Jan 2005 09:11:55 -0000, "Bob Phillips"
    <[email protected]> wrote:

    >I think Chuck would mean
    >
    > Range("A1:A5").ClearContents


    YIIKES! <g> That deleted the contents as well as clearing the
    selection! Any way to _just_ de-select (clear the selection) while
    keeping the "cursor" in the same cell as before invoking the macro?

    Thanks much!

    >--
    >
    >HTH
    >
    >RP
    >(remove nothere from the email address if mailing direct)
    >
    >
    >"CLR" <[email protected]> wrote in message
    >news:%[email protected]...
    >> Maybe.............
    >>
    >> Range("A1:A5").Select
    >> Selection.ClearContents
    >>
    >>
    >> Vaya con Dios,
    >> Chuck, CABGx3
    >>
    >> "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote in message
    >> news:[email protected]...
    >> > I currently have the selection clear by changing the cursor location
    >> > to cell D2 (Range("D2").Select). So if the entire sheet had all the
    >> > cells selected, this would clear the selection but would also move to
    >> > another location. I actually need the active cell to remain the same
    >> > as before the macro was invoked, but don't know the VB code for this.
    >> >
    >> > Thanks for any help in advance.
    >> >

    >>
    >>

    >



  7. #7
    StargateFan
    Guest

    Re: VB coding to clear a selection?

    On Sat, 29 Jan 2005 12:27:20 +0100, "Harald Staff"
    <[email protected]> wrote:

    >See also
    >http://www.*****-blog.com/archives/2...-and-activate/
    >for some theory.
    >
    >HTH. Best wishes Harald


    Very interesting, brings up the question on whether my
    keystrokes-recorded macro would work, then, without selecting the
    _entire_ worksheet. Seems like it would, but thought I'd ask. I
    invoke this toolbar macro after copy/pasting a bunch of data into
    Excel. Since invoking with full attributes means that the data
    structure remains intact (very important), I created the macro to
    quickly and easily re-format the pasted in text to what the rest of
    the sheet is for easier editing and for a proper final look.

    But as I'm working on different rows, the problem has been that the
    way I've been clearing the selection itself is to just hit Ctrl+Home
    which takes me to the top cell in the sheet. Not sure that this
    situation falls under the troubles the website above talks about as
    the _entire_ worksheet is selected.

    Thanks!

    >"StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> skrev i melding
    >news:[email protected]...
    >> I currently have the selection clear by changing the cursor location
    >> to cell D2 (Range("D2").Select). So if the entire sheet had all the
    >> cells selected, this would clear the selection but would also move to
    >> another location. I actually need the active cell to remain the same
    >> as before the macro was invoked, but don't know the VB code for this.
    >>
    >> Thanks for any help in advance.
    >>

    >



  8. #8
    StargateFan
    Guest

    Re: VB coding to clear a selection?

    On 29 Jan 2005 04:26:12 -0800, "NC" <[email protected]> wrote:

    >hi stargatefan
    >do you want clear the contents or just get rid of the selected
    >cells(i.e.deactivating them) & again activate the cell on which you was
    >working before.


    Ah, the problem was in the terminology. I'm actually just
    de-activating the selection again.

    >you can do this by using a temporary range which you can declare equal
    >to your active cell(s) then run the macro & then again activating this
    >temporary range.


    Lordy, that's beyond my limited VB knowledge! <g> Ah well, I'll just
    keep working with what I have, I guess, unless/until something else
    comes along.

    Thanks much!

    >Regards
    >NC



  9. #9
    Ken Wright
    Guest

    Re: VB coding to clear a selection?

    ActiveCell.Select

    --
    Regards
    Ken....................... Microsoft MVP - Excel
    Sys Spec - Win XP Pro / XL 97/00/02/03

    ----------------------------------------------------------------------------
    It's easier to beg forgiveness than ask permission :-)
    ----------------------------------------------------------------------------

    "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote in message
    news:[email protected]...
    > On Sat, 29 Jan 2005 09:11:55 -0000, "Bob Phillips"
    > <[email protected]> wrote:
    >
    > >I think Chuck would mean
    > >
    > > Range("A1:A5").ClearContents

    >
    > YIIKES! <g> That deleted the contents as well as clearing the
    > selection! Any way to _just_ de-select (clear the selection) while
    > keeping the "cursor" in the same cell as before invoking the macro?
    >
    > Thanks much!
    >
    > >--
    > >
    > >HTH
    > >
    > >RP
    > >(remove nothere from the email address if mailing direct)
    > >
    > >
    > >"CLR" <[email protected]> wrote in message
    > >news:%[email protected]...
    > >> Maybe.............
    > >>
    > >> Range("A1:A5").Select
    > >> Selection.ClearContents
    > >>
    > >>
    > >> Vaya con Dios,
    > >> Chuck, CABGx3
    > >>
    > >> "StargateFan" <IDon'tAcceptSpam@IDon'tAcceptSpam.com> wrote in message
    > >> news:[email protected]...
    > >> > I currently have the selection clear by changing the cursor location
    > >> > to cell D2 (Range("D2").Select). So if the entire sheet had all the
    > >> > cells selected, this would clear the selection but would also move to
    > >> > another location. I actually need the active cell to remain the same
    > >> > as before the macro was invoked, but don't know the VB code for this.
    > >> >
    > >> > Thanks for any help in advance.
    > >> >
    > >>
    > >>

    > >

    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1