Copying formulae down a variable number of rows

Ajtoo

New Member
Joined
Mar 14, 2002
Messages
5
A sheet imports data into the first three columns of a blank sheet. This data always contains a different number of rows, i.e. it may be anything from 10 to 10,000.
I now wish to copy formulae from a separate sheet, to work on the new data in cols 1-3, to the fourth column and down the required number of rows.
How can a macro recognise how many rows to copy down?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi Ajtoo


Try this

Sub DoIt()
Range("A1", Range("C65536").End(xlUp)).Copy _
Destination:=Sheet2.Range("A1")
End Sub
 
Upvote 0
The following code counts the number of used rows in column A and sets the number to the variable NumRows:
dim NumRows as long
Range("A1").Select
NumRows=Range(Selection, Selection.End(xlDown)).Count

Hope this helps.
Kind regards, Al.
 
Upvote 0
On 2002-03-15 07:56, Ajtoo wrote:
A sheet imports data into the first three columns of a blank sheet. This data always contains a different number of rows, i.e. it may be anything from 10 to 10,000.
I now wish to copy formulae from a separate sheet, to work on the new data in cols 1-3, to the fourth column and down the required number of rows.
How can a macro recognise how many rows to copy down?


Dim NumRows As Long
NumRows = Intersect(ActiveSheet.UsedRange, Columns("A:C")).Rows.Count
 
Upvote 0

Forum statistics

Threads
1,214,533
Messages
6,120,076
Members
448,943
Latest member
sharmarick

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