# Xl Macro To Count Consecutive Rows of Data Starting From Specific Cell

#### ggelineau

##### Board Regular
I recorded a macro that will be used to reformat a spreadsheet every day. The spreadsheet to be reformatted is always consistent except in terms of the amount of rows of data, which causes a problem for my macro since I need to insert formulas into cells within row thirteen and then copy those formulas down to the last row of data.

The titles for the Data always start in Cell A12, so the data will always start in Cell A13 and go from there. There are some rows of miscellaneous information below the data (there are blank cells between the data and this misc. information) so I will need to count, starting at A13, the amount of rows that contain data without interruption (i.e. no blanks).

I will then need to enter the count as the row number in a bunch of statements similar to the one below, where I entered a formula on the 13th row and then copied it down to the last row.

Range("D13").Select
Selection.AutoFill Destination:=Range("D13:D??")

I am truly stumped on how to not only create the count code but also how to go about adding the count so that it is accepted as the row number within the code above.

Any help is much appreciate.

Thanks,
G

### Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

#### VoG

##### Legend
Try

Code:
``````Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
Range("D13").AutoFill Destination:=Range("D13:D" & lr)``````

#### Andrew Poulsom

##### MrExcel MVP
Try:

Code:
``````Dim LastRow as Long
LastRow = Range("A13").End(xlDown).Row
Range("D13").AutoFill Destination:=Range("D13:D" & LastRow)``````

#### DonkeyOte

##### MrExcel MVP
will copy D13 to all rows in D untils such time as a blank appears below A13.

Code:
``````Dim rng As Range
Set rng = Range(Cells(13, 4), Cells(13, 1).End(xlDown).Offset(0, 3))
Cells(13, 4).AutoFill Destination:=rng``````

#### ggelineau

##### Board Regular
Thank you all VERY MUCH. This is going to help tremendously!!!

Thanks Again,
G

Replies
2
Views
2K
Replies
7
Views
1K
Replies
3
Views
260
Replies
6
Views
686
Replies
2
Views
552

1,191,165
Messages
5,985,034
Members
439,935
Latest member
Monty238

### 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.

### Which adblocker are you using?

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

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