+ Reply to Thread
Results 1 to 4 of 4

How to de-select pasted cells?

  1. #1
    Forum Contributor
    Join Date
    08-22-2005
    Location
    Denmark
    MS-Off Ver
    Excel 365
    Posts
    349

    How to de-select pasted cells?

    I have a macro that inserts a line i a table:
    1. insert a line just above the bottom line
    2. offset one step down
    3. copy bottom line from col. A to S
    4. offset one step up
    5. paste into the new next-bottom line
    After this I want to delete the cells in the new line in column B, C and D. The problem is that after the pasting, all the newly pasted cells stay selected. Trying to select col. B, C and D only moves the complete selection three steps to the right so that upon deletion the complete contents are deleted.

    How can I de-select the pasted values?
    I sometimes use Application.CutCopyMode = False, but it does't work here.

    Please Login or Register  to view this content.
    /NSV

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    You should always avoid selecting cells when possible.

    This code should help. Note it's matches your code exactly which from what I can see is not how I would do it. Basically you just want to insert the row and the Col A value to copy into the new row.

    Therefore no need for this line

    Please Login or Register  to view this content.
    if you slight mod my code

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    08-22-2005
    Location
    Denmark
    MS-Off Ver
    Excel 365
    Posts
    349
    More specifically I need to copy the cells in the A-, in the E- and in the H to S columns.

    Thanks for the tips. I've seen before that one should avoid to select, but my knowledge about VBA comes from analyzing the recorded code, so it is a bit difficult to optimize anything.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Please Login or Register  to view this content.
    VBA Noob

+ 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