![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: London
Posts: 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? |
|
|
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Hi Ajtoo
Try this Sub DoIt() Range("A1", Range("C65536").End(xlUp)).Copy _ Destination:=Sheet2.Range("A1") End Sub |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
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. |
|
|
|
|
|
#4 | |
|
New Member
Join Date: Mar 2002
Posts: 4
|
Quote:
Dim NumRows As Long NumRows = Intersect(ActiveSheet.UsedRange, Columns("A:C")).Rows.Count |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|