Copy cell data Workbook to Workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to copy the contents of the
active sheet in the active workbook to
sheet1 of a second named workbook.

I get an error when starting loop to
check each cell[range] in the Active
Sheet.

What am I doing wrong? Much Thanks...

Paul


Dim oRange As Range

Dim MatrixWB As Workbook
Dim ActiveWB As Workbook

Set MatrixWB = Application.Workbooks("AssemblyMatrix.xls")
Set ActiveWB = Application.ActiveWorkbook
'Error when trying to check each cell in the Active sheet?
For Each oRange In ActiveWB.ActiveSheet

If Not oRange.Value = "" Then
With MatrixWB.Sheets("Sheet1")
.Cells(oRange.Row, oRange.Column).Value = _
oRange.Value
End With
End If

Next oRange
 
Perfect...Thanks

Tom Ogilvy said:
For Each oRange In ActiveWB.ActiveSheet.UsedRange

--
Regards,
Tom Ogilvy

Soli3d said:
Hello,

I am trying to copy the contents of the
active sheet in the active workbook to
sheet1 of a second named workbook.

I get an error when starting loop to
check each cell[range] in the Active
Sheet.

What am I doing wrong? Much Thanks...

Paul


Dim oRange As Range

Dim MatrixWB As Workbook
Dim ActiveWB As Workbook

Set MatrixWB = Application.Workbooks("AssemblyMatrix.xls")
Set ActiveWB = Application.ActiveWorkbook
'Error when trying to check each cell in the Active sheet?
For Each oRange In ActiveWB.ActiveSheet

If Not oRange.Value = "" Then
With MatrixWB.Sheets("Sheet1")
.Cells(oRange.Row, oRange.Column).Value = _
oRange.Value
End With
End If

Next oRange
 

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

Back
Top