ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VB Question (https://www.excelbanter.com/excel-discussion-misc-queries/140473-vbulletin-question.html)

Stan

VB Question
 
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!

Dave Peterson

VB Question
 
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.

Stan wrote:

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!


--

Dave Peterson


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com