Count Cells with Values in a Range Then Use it to create rows

hamistasty

Board Regular
Joined
May 17, 2011
Messages
208
I want vba code to give the Sum of column A in Sheet("Schedule") from row 9 onwards until there is no value in a cell.

Then I want the code to Copy row 13 of Sheet("Index") and insert it below the same row the amount of times that the previous code counted in the other sheet.

Appreciate any help..
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Something like this..? Obviously it's wrong, but I can't work out how to copy and paste the row for the count in Schedule.

Code:
Sub CreateIndex()
Dim I As Long
 
 For I = 9 To Sheets("Schedule").Range("A" & Rows.Count).End(xlUp).Row
 
 Sheets("Index").Range("C13").Copy
Next I
 
End Sub
 
Upvote 0
May Be something like this
Code:
Sub Test()
Dim LR As Long, ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets("Schedule")
Set ws2 = Sheets("Index")
LR = ws1.Range("a" & Rows.Count).End(xlUp).Row
ws1.Range("b2").Value = WorksheetFunction.Sum(ws1.Range("a9:a" & LR))
ws1.Range("b3").Value = ws2.Range("A13").Value
End Sub
 
Upvote 0
Not sure if it works, but thanks. It needs to count starting at A9 in the line:

Code:
LR = ws1.Range("a" & Rows.Count).End(xlUp).Row

How can I start the count at row 9??
 
Upvote 0
Never mind. I'm not sure how this is supposed to work. It isn't creating rows from C13 onwards in Index (the amount of times being the Count of values in each row from A9 down until a null value is reached.)

Any other ideas?
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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