Archive for the ‘Copy and Paste’ Category.

Catching Paste Operations

You know the situation: You have carefully setup a workbook with intricate Validation schemes. But then along comes your user and he copies and pastes at will. Result: Validation zapped, workbook structure violated.

What to do? The only way I find to be reliable is to catch all possible paste operations. But this isn’t very easy, since there are a zilion ways to paste.

I have put together a sample workbook and an explanatory article on how one could go about protecting a workbook by intercepting paste operations.

Let me know what you think!!

Regards,

Jan Karel Pieterse
www.jkp-ads.com

Transposing the Formulas in a Table of Cells

OK, time for some non Excel 2007 stuff…

Recently someone asked me if it was possible to transpose a table of cells, but in such a way that the formula of each cell is kept intact. I decided VBA was the way to go and produced a small but very useful little routine for that.

What the poster wanted is to go from:

To:

Read on here.

Regards,

Jan Karel Pieterse

JKP Application Development Services

Founding member of:
Professional Office Developers Association

Automating pastevalues

There are a lot of good comments on the mouse shortcut entry to Paste Values. I am curious though, because I haven't seen one variation of a macro to Paste Values that I thought was more straightforward.

The commented method involves two steps, one, to copy the range, and two, to perform the Paste Special, something like:

Sub CopyPasteValues()
   Selection.Copy
   Selection.PasteSpecial Paste:=xlPasteValues
End Sub

The other alternative, is to use the .Value property of the range, like this:

Sub ValueToValue()
    Selection.Value = Selection.Value
End Sub

So, what's your take, is one better than the other? In theory I would think that the second one would be faster. It's only one operation, and Excel doesn't have to keep the range in memory to perform the paste special. I'm not sure how either method works with discontinuous ranges.

Mouse shortcuts

So Dick is the keyboard guru here, but there's a lot of people that use the mouse a lot. I know I do. And I was reading Jensen Harris' blog today about how a Paste Special operation takes 6 clicks right now, but only 3 in Office 12.

However, there are a number of ways in which you can shorter this operation. One way, is to customize the toolbars, and display the 'Paste Values' button as shown in the screenshot.

The steps required to add this button are:

  1. Right click on any toolbar, and click 'Customize'
  2. Click on the 'Commands' tab
  3. Select the 'Edit' category
  4. Scroll down in the commands list until you see the 'Paste Values' button
  5. Click and drag this button to the toolbar where you want it.
  6. Click on 'Close' and you're done!

This reduces the number of clicks needed to 3 (Select Range, click on Copy, click on Paste Values).

However, there's another method that blows people away each time I use it... it's that cool factor I guess.

Take this data for example, I'm using =RAND(), just like Jensen is.

Now, select the range, right click and hold on one of the borders (*not* in the fill handle), drag the range as if you were going to move it to a different place, and then drag it back to its original position. Just offseting one row or column willl do the job.

When you release the mouse button, a popup menu will appear, giving you some pretty cool options, one of those being 'Copy here as Values only'. Basically doing the Copy and Paste in one single operation.

I guess technically this is still a 3 click operation, but there's a lot less mouse movement involved, and, you can use it to create links or hyperlinks for example.