Hale, Jim
Jim.Hale at FleetPride.com
Tue Mar 21 09:00:59 CST 2006
Guilty as charged. I knew I would get called on it as soon as I hit the send button. I have already had a stern talking to myself. :-) Jim Hale -----Original Message----- From: Bobby Heid [mailto:bheid at appdevgrp.com] Sent: Tuesday, March 21, 2006 7:10 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Export to Excel via VBA, Naming Cells Jim, Nice example. But I'd like to point out one thing, if I may. I think it is a better practice to exit a for loop with an Exit For statement instead of jumping out of the loop. Bobby -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Friday, March 17, 2006 4:27 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Export to Excel via VBA, Naming Cells Maybe this will give you some ideas. Starting at the top of the range e5 it finds the last number in the column and places a sum formula underneath. Jim Hale Function test() Dim rng As Range, i As Integer, strAddressBottom As String, strAddressTop As String Set rng = Range("e5") strAddressTop = rng.Address For i = 1 To 25 If rng.Offset(i, 0).Value = "" Then strAddressBottom = rng.Offset(i - 1, 0).Cells.Address rng.Offset(i, 0).Formula = "=sum(" & strAddressTop & ":" & strAddressBottom & ")" GoTo The_End End If Next The_End: Set rng = Nothing End Function -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email.