Compile Error:Expected Array

F

Fatima CN

Hi,
I am getting an error as (Compile Error:Expected Array) when i am
running the below macro.Pls help me to debug it


Sub copyVisible()
Dim copyFrom As Range
Set copyFrom = ThisWorkbook.Sheets("Analysis").Range("C5")
Do
Set copyFrom = copyFrom.Offset(1)
Loop Until copyFrom.EntireRow.Hidden = False
copyFrom.Copy
Sheets("PG_results").Select
Selection.PasteSpecial Paste:=xlPasteValues("PG_results").Range("B5")
Application.CutCopyMode = False
End Sub





*** Sent via Developersdex http://www.developersdex.com ***
 
T

Tim Williams

You can skip the copy/paste and just assign the value directly
Sub copyVisible()
Dim copyFrom As Range
Set copyFrom = ThisWorkbook.Sheets("Analysis").Range("C5")
Do
Set copyFrom = copyFrom.Offset(1)
Loop Until copyFrom.EntireRow.Hidden = False

Sheets("PG_results").Range("B5").Value = copyFrom.Value


Tim
 
P

p45cal

Try changing:

Sheets("PG_results").Select
Selection.PasteSpecia
Paste:=xlPasteValues("PG_results").Range("B5")
to:

Sheets("PG_results").Select
Range("B5").Select
Selection.PasteSpecial Paste:=xlPasteValues
or shorter and without selecting:

Sheets("PG_results").Range("B5").value=copyFrom.value

not tested - (in haste)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top