View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
FARAZ QURESHI FARAZ QURESHI is offline
external usenet poster
 
Posts: 553
Default COPY PASTE VALUES ONLY FROM/ON VISIBLE CELLS

Thanx again Joel!

However, the problem still remains. First of all:

1. I think instead of:
Set VisibleCells = activesheet.cells.SpecialCells(xlCellTypeVisible)

it should be:
Set VisibleCells = selection.cells.SpecialCells(xlCellTypeVisible)

so as to avoid application on each and every visible cell on the sheet
taking up a neverending exercise.

And

2. The button inserted via the CustomUIEditor on the XML ribbon to run the
code, upon being clicked, is still giving the same error as earlier, i.e.:

Wrong number of arguments or invalid property assignment

"joel" wrote:

Sub PstVal2VisCls()
Set VisibleCells = activesheet.cells.SpecialCells(xlCellTypeVisible)
For Each CELL In VisibleCells
CELL.Copy
CELL.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Next
End Sub

"FARAZ QURESHI" wrote:

I know that Joel, but unfortunately you didn't understand my question. I want
the formulas of the visible cells to be CONVERTED to values while remaining
at their place. I have even developed the following code:

Sub PstVal2VisCls()
Selection.SpecialCells(xlCellTypeVisible).Select
For Each CELL In Selection
CELL.Copy
CELL.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Next
End Sub

But the problem now is that when I try to access it via a button on the
ribbon the result is a dialog box stating:

Wrong number of arguments or invalid property assignment

while being played via VBA by F5 it is working great.

"joel" wrote:

You can select the visible cells only by using the menu
Edit - goto and then pressing SPECIAL button. Once you selected the
visiable cells you can copy and use PasteSpecial with values to remove the
formulas.

"FARAZ QURESHI" wrote:

I have a list with a column containing formulas. With some rows
hidden/filtered I want to copy the visible cells and copy paste special the
values of only visible cells upon the same, leaving the formulas on the
hidden cells.

Any idea/macro/code?

Thanx!