+ Reply to Thread
Results 1 to 11 of 11

Selecting One Cell Copies Range

  1. #1
    Registered User
    Join Date
    08-15-2008
    Location
    SLC
    Posts
    7

    Selecting One Cell Copies Range

    Hi,

    Question 1) Is there a way that whenever I select Cell B39 that it will copy cells B39:V39 ? From there I can manually paste that selection to where I need to.

    If this is possible, it would save the effort of having to select B39:V39 manually and clicking CTRL-C. I am gathering data and the copying and pasting is killing me.



    Question 2) Is it possible that when I click on Cell A9 that it can paste any data that I just copied from another worksheet to cells A9:D29? The size of the selection that I would copy is the same size as A9:D29 (4 columns & 29 rows).



    I have searched for a solution, but I am not having much luck since I am anaware of the proper terminology for these types of actions.

    Thank you.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi, and welcome to the forum,


    You could use the following code in the Worksheet Selection_Change event to achieve both objectives.

    Please Login or Register  to view this content.
    HTH

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    'These instructions pre typed & are worded to cater for the novice programmer
    'To install macro to correct location

    'Copy this macro
    'GoTo Excel
    'Select sheet this is to appy to
    'Right Click on Sheet Name Tab > select View Code
    'Past macro into the Worksheet Module displayed


    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  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
    Move to programming.

    Here's a variation on Richard 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 !!!

  5. #5
    Registered User
    Join Date
    08-15-2008
    Location
    SLC
    Posts
    7

    Paste works, still some problems with Copy

    WOW !

    You guys Rock!


    For Pasting
    I tried all three of them and they all work very well. I am soooooo happy!
    I added the On Error Resume Next, because I was getting an error if i didn't have anything to paste.


    For Copying

    I had some trouble at first. When I would paste the contents of B39, all I would get were $0.00 $0.00 . . .etc.

    When I select Paste Special > Values and number formats It does paste the results that I wanted.


    I do several copy and pastes from 3 different workbooks so this is going to work very well.


    Question 1

    For one of the workbooks, can I adapt. . .
    Please Login or Register  to view this content.

    . . .so that it also does the Paste Special > Values and number formats steps as well?



    Question 2
    I have a workbook with a very long list that is contained in 5 columns (A B C D E). I copy a section from column A to column D that is always 21 rows deep. I then paste that to another workbook using your fine code from above. I then come back to the original workbook and copy a different section from columns A to D. (Always Copy A to D and 21 rows deep).

    Can I add code to this worksheet so that when I click on any cell in column A -it will then copy the data from that point over to column D and down 21 rows?

    If that can be done - then the I will not have to worry about getting carpel tunnel.
    The process will be as easy as click, click, click.

    Thanks so much for your help. I am very pleased with what I can do already.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Glad we could help. I realise I didn't use the ranges you'd originally specified, (I'm always doing that when testing these things!), but I guess you sorted it out.

    One other point. It's OK to use On Error Resume Next, but it needs to be done with care, otherwise you could end up with unexpected results. As soon as you're past the bit of code where you want to avoid an Application error, reset it with On Error GoTo 0 , so that any subsequent error will be flagged up.

    Rgds

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Q1. Unless it's changed in Excel 2007, I've never found a quicker way than performing two pastes. i.e.

    Please Login or Register  to view this content.

    Q2. Use:

    Please Login or Register  to view this content.
    HTH

  8. #8
    Registered User
    Join Date
    08-15-2008
    Location
    SLC
    Posts
    7

    Almost there.

    Q1

    Please Login or Register  to view this content.
    Works just fine. Thank you.




    Q2.

    Please Login or Register  to view this content.

    That code takes the value from say A8 and copies it to D29.


    I would like to click on A8 and have cells A8:D28 (4 cols & 20 rows starting at A8 and ending at D28) copied so that I can paste them into another workbook.

    If I click on A8 it copies A8:D28
    If I click on A43 it copies A43:D63
    If I click on A71 it copies A71:D91


    It is very satisfying to finally get things working in my favor.

    Thank you so very much for your help.
    Last edited by mudraker; 08-15-2008 at 09:01 PM.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    OK, understood.

    Use:

    Please Login or Register  to view this content.

  10. #10
    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
    Or using resize

    Please Login or Register  to view this content.
    VBA Noob

  11. #11
    Registered User
    Join Date
    08-15-2008
    Location
    SLC
    Posts
    7
    Thank you.

    Richard and VBA Noob both of your suggestions work just grand!

    Thanks again!

+ 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