Morning all,
Would anyone know if there's a way to auto-paste copied data from the clipboard into a cell upon a single left-click? If so, I'd need this to apply to ONLY cell range A3:A50.
Thanx a lot,
Frithlethrend
Morning all,
Would anyone know if there's a way to auto-paste copied data from the clipboard into a cell upon a single left-click? If so, I'd need this to apply to ONLY cell range A3:A50.
Thanx a lot,
Frithlethrend
Hello frith,
Welcome to the Forum!
Is this for only a single worksheet or all worksheets in the workbook?
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Star below the post.3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Please Login or Register to view this content.
Hey, thanx, that works great - only thing is I need it to work with the existing Worksheet_SelectionChange, below:
Please Login or Register to view this content.
Sorry, I forgot this was in there. Any way to "blend" them such that they don't conflict?
Thanx again,
Frith
Please Login or Register to view this content.
Frith, please take a few minutes to read the forum rules about crossposting.
Thank.
Entia non sunt multiplicanda sine necessitate
Hi again,
I sure will... Also, a problem arose with that code - whenever the clipboard is empty and I click a cell in that range, I get a runtime error ("paste failed"). Any way to avoid this annoyance, other than having some kind of "default data" always pre-loaded on it? Also, I have cells in column A merged with those in B, which somehow disallows this code from executing...?
Thanx,
Frith
Last edited by frith; 05-26-2011 at 01:44 PM.
The problem with this approach is that the clipboard could have just about anything in it, which could lead to all sorts of issues. The code below will at least notify the user if the clipboard is empty and will not stop the code.
As for the issue of the merged cell, this bit here:Please Login or Register to view this content.
Says to only run the encapsulated code only if one cell is selected. If more than one is selected, then the code will not do anything. I added this because I didn't know how you would want to handle things like the user selecting the entire column, or the entire sheet. It would mean pasting to ALL cells selected.Please Login or Register to view this content.
Thank you, indeed... Just one thing with the merged cell issue, Ummm... It's still doing nothing when I click it (say, A5, which is really "A5 merged with B5")... That 2nd, seperate code block you posted... am I supposed to do something with that?
TY,
Frithlethrend
What I am saying is because those cells are merged, when you select that merged cell, you are actually selecting 2 or more cells. The code I supplied specifically only runs when one cell is selected. This is to prevent issues that will occure if the user selects the entire column, row, sheet, or just a large range. If that test for Target.count were not in there, the code would paste to each and every cell selected, and therefore turn your sheet into garbage.
There are a few potential solutions for you:
1: Remove the If Target.Count = 1 statement. This, like I say above, could lead to major issues if your users do not think before they act.
2: Change the If Target.Count = 1 statement to something like If Target.Count < 5. This will still mean the clipboard will be pasted into each cell selected, but at least it is only five cells, and hopefully the user will know what they are doing.
3: You could add a loop that runs through each cell in the Target range and pastes into only cells within the range of A3:A50
4: Have the code only paste to the Active cell.
5: Prompt the user before pasting to ensure they want to paste into the selected cells.
These are just a few options, but without knowing specifically what you are trying to accomplish, I can't make any one recommendation.
Is there a reason those cells are merged? Cell merging can wreak havoc on code, especially when you are pasting. I recommend avoinding merging cells unless completely unavoidable.
Hi,
Option 2 worked fine for merged cells. Actually, if I select more than 1 merged cell, nothing even gets pasted; it only works if I select just 1 cell, which is what I needed.
Thanx again!!
Hi Whizbang,
Sorry to belabor the thread, but I ran into another issue with that pasting code: it works perfectly when copying/pasting within "EXCEL", but it doesn't work when copying data from an outside App. (It's a proprietary App. you've probably never heard of, but is windows-based). When I try to paste, that "empty clipboard" message appears, even though I can still paste the data via double-clicking a cell... Any ideas on how to make this work (elsewise I'm screwed)?
Thanx yet again,
Frith
Try this.
Please Login or Register to view this content.
Sweet... But I just noticed that when it pastes, it overides the cell format (i.e., it pastes the wrong font, alignment, etc.) Any way to only paste the "value"? Also (sorry), is it possible to have this code only paste ONE time (i.e., execute only on the initial paste, per cell)?
Thanx,
Frith
Last edited by frith; 05-27-2011 at 01:13 PM.
Try this:
Please Login or Register to view this content.
I am not sure what you mean by the second question. Do you mind clarifying and providing examples?
Hey again...
Yeah, the format issue is good, but it still allows for subsequent auto-pasting... I'm just trying to get it so that if I auto-paste "hello" now, it won't auto-paste "goodbye" five seconds later in the same cell subsequently (i.e., I want "hello" to get pasted in A5 the 1st time, but not "goodbye" the 2nd time in A5, etc., etc.). However, I would need to allow for "manual" cell edits.
Thanx and sorry for the trouble,
Frith
Ah. I see what you mean, now.
The code below tests the active cell (the cell you click) to see if it is blank. If it is blank, it will paste. If not, it will not paste and just let you edit normally.
Please Login or Register to view this content.
Awesome - great job! What comes around, goes around...
Frith
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks