Expected Array

brulet

New Member
Joined
May 6, 2011
Messages
20
Is there a way to copy a value from one cell to another, without using select? Same workbook, different worksheet. This line is causing an error "Expected array". lstrw is the lastrow and is an int.

<code>
For i = 0 To (lstrw)
sheets("Output").Range("A1").Offset(i, 0).Value = sheets("Site2").Range("A1").Offset(i, 0).Value
Next i
End Sub

</code>

Thanks again,
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You should not need to loop

Code:
Sheets("Output").Range("A1").Resize(lstrow).Value = Sheets("Site2").Range("A1").Resize(lstrow).Value
 
Upvote 0
You should not need to loop

Code:
Sheets("Output").Range("A1").Resize(lstrow).Value = Sheets("Site2").Range("A1").Resize(lstrow).Value

It still gives me expected array. I was using a loop, because I was calculating something in the next column, as the first column was filled.

Thanks again,

BT

<code>
sheets("Output").Range("A1").Resize(lstrow).Value = sheets("Site2").Range("A1").Resize(lstrow).Value
For i = 0 To (lstrw)
monthWorkingIn = month(sheets("Output").Range("A1").Offset(i, 0))
sheets("Output").Range("B1").Offset(i, 0) = interpolate(sheets("Site2").Range("B1").Offset(i, 0), Worksheets("Site2.Frequency." & month).Range("G2:G16"), Worksheets("Site2.Frequency." & month).Range("F2:F16"))
Next i
</code>
 
Upvote 0
What is interpolate? Which line of code gives the error?

Still the same line

"sheets("Output").Range("A1").Resize(lstrow).Value = sheets("Site2").Range("A1").Resize(lstrow).Value"

I can comment out the interpolation with no effect. Interpolate is a custom function to log interpolate. It works, as I use it with a test function without a problem.
 
Upvote 0
This works fine for me

Code:
Sub test()
Dim lstrow As Long
lstrow = Sheets("Site2").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Output").Range("A1").Resize(lstrow).Value = Sheets("Site2").Range("A1").Resize(lstrow).Value
End Sub
 
Upvote 0
What is lstRw? Is it a function?
 
Upvote 0
And how is i declared?
 
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,165
Members
449,295
Latest member
DSBerry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top