Autofill Until

U

uberathlete

Hi all! I've got this macro in Sheet 1 (attached):

Sub abc()
Set rng = Range(Range("B4"), _
Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If Not IsEmpty(cell) And _
InStr(1, cell.Value, "total", _
vbTextCompare) = 0 Then
Range("D3").Copy cell.Offset(0, 2)
End If
Next
End Sub

and it basically autofills all cells in column D from D3 downwards
except for those cells with no corresponding value in the B column and
those with "Total". I would just like to modify the macro such that the
autofill stops once it reaches the F cell whose corresponding column B
cell has a value of "Total Group 2". Anyone know how this can be done?
Any help will be greatly appreciated. Thanks!


+-------------------------------------------------------------------+
|Filename: Sheet 1.JPG |
|Download: http://www.excelforum.com/attachment.php?postid=4028 |
+-------------------------------------------------------------------+
 
U

uberathlete

Hey Tom! Well, assume that in sheet 1, there is a value in B19, say "Al
Groups". The macro autofills all the way down to D19 also. How would
modify this such that it stops right at the F cell with a correspondin
B cell value of "Total Group 2"
 
T

Tom Ogilvy

Sub abc()
Set rng = Range(Range("B4"), _
Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If Not IsEmpty(cell) And _
InStr(1, cell.Value, "total", _
vbTextCompare) = 0 Then
Range("D3").Copy cell.Offset(0, 2)
End if
If Instr(1,cell.Value,"total group 2", _
vbTextCompare) then
exit sub
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"uberathlete" <[email protected]>
wrote in message
news:[email protected]...
 

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