VB Question

G

Guest

I'm trying to get some help with VB code that auto-fills cell C2 through the
cell in column C where the word "Total" appears in colum A.

In this example, it would begin in cell C2 and needs to Auto-Fill down to
Row 4 since Cell A4 contains the word "Total"

Column A Column B Column C
row1 Test1 5 30%
row2 Test2 3
row3 Test3 7
row4 Total 15

Here's what I have so far although I need the range to be through the row
where the word "Total" appears in column A.

Range("C2").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("C2:C47")
Range("C2:C47").Select



Many thanks if you can help!
 
D

Dave Peterson

Maybe...

Dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row - 1
.range("C2").autofill destination:=.range("c2:C" & lastrow)
end with

It actually just looks at the last used row in column A, then subtracts 1. So
if you have data in column A under the Total row, this won't work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top