Ok, what i have done is to make two labels : "copy" and "paste" apear near the active cell, when copy is clicked, the value and the formating are copied in a static array of "SavedRanges" that is actually a user defined type witch contains a Value as a Variant, a x and y coordinates of the cell from the first copied cell, and a format as a string, witch is actually the NumberFormat property of a range object. When copy is clicked it automatically static allocates the array to the number of cells selected (note here that you can only static allocate an array of max 32768 items), and copies the information formating and coordinates to each item. When paste is clicked it gets the date from that array, and puts it from the active cell,to the cell specified by the ActiveCell's position plus the coordinates for the pasted cell. It works fine, about as fast as the normal copy-paste, the troubles are: limited number of cells pasting (that is a problem when you select entire columns), it is not compatible with the normal copy-paste, if you want to copy from/to another worksheet, you will have to use a normal copy paste, with special attention to not selecting any other cell in the worksheet with events, the last problem is with the usage, clicking a small label near the active cell is not that easy as pressing ctrl+c (also because one is always very used to it), and the labels may also make it harder to select the cell near by, so I've added the possibility of displaying the labels in a fixed place.
the ModuleClipboard:
and its usage in the worksheet module:
For usage of the combination keys ctrl+c/v, i was thinking of creating an invisible form that takes focus when a cell is selected, and its only purpose to be for listening for key press, but that would be tricky to solve the way to move the focus from the form to the worksheet if other keys are pressed (to modify the cell or to select another). So I'm not sure this would work.
I have also used a modified version of the code in that link above to undo a macro I was using that modified cells, but I still can't think of a way to undo normal actions (other than saving from time to time, and undoing to a specified time, but this would be very resource and time consuming so I've let the user choose when to save
). That is because when someone modifies a cell, the event triggered at the change already finds the modified value, would have been usefull a "before change" event.
Bookmarks