Pasting over hidden columns

H

Huber57

I have hidden some rows in my workbook. I would like to paste some data
over these hidden cells and allow the data to skip them.

For example, if I have hidden Columns B and C and I paste 1, 2, 3, 4 (all
from different cells) into a row, 1 should appear in A1, 2 should appear in
D1, 3 should appear in E1, etc. Do you know how I can skip hidden rows when
I paste data?

I am using Excel 2003.

Sincerely,

huber 57
 
D

Dave Peterson

I think you'll have to copy and paste in pieces--do each area of the visible
range separately.
 
B

BizMark

Easy. After selecting your range:

1. Go to the 'Edit' menu
2. Select 'Go To...'
3. Ignore the first dialog that appears and click 'Special...'
4. Check 'Visible Cells Only' (right-hand side, 3rd option from
bottom)
5. Click 'OK'

Then do your Paste/whatever other function you wish to apply only to
the visible cells in the selected range.

Regards,
MB
 
P

Peo Sjoblom

Have you really tried this, it certainly does not work for me? Hide columns
B and D, put 1 in H1, 2 in I1 and 3 in J1, copy H1:J1, now select columns
A:E, go to special and select visible cells only, paste the values, what do
you get?
 
B

BizMark

You're quite right!
It works IF the source selection is a single cell, and not if the
source selection is multiple cell.

You could try the following though, assigning them to a couple of
shortcut keys:

'###CODE BEGINS HERE
Public xSel As Range

Sub CopyCustom()
Set xSel = Selection.Cells
End Sub

Sub PasteCustom()
nCell = 0

For Each xCell In Selection.Cells
If Not (xCell.EntireRow.Hidden Or xCell.EntireColumn.Hidden) Then
nCell = nCell + 1
xCell.Value = xSel.Cells(nCell).Value
End If

If nCell = xSel.Cells.Count Then
nCell = 0
End If
Next xCell
End Sub
'###CODE ENDS HERE
 
Top