Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2004, 02:22 AM
Authorized User
 
Join Date: Jan 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine the number of data rows in a sheet

Hi!

I have 2 doubts. Please clarify these:

1) How to determine how many rows in a sheet are filled with data?
2) I want to autofill entry in cell AD3 in all the rows (containing data), below it. How shud I do it. I tried it thru recording macro. But then, the no. of rows got fixed. What will i do when tmrw the number of rows will change. Here is the code that needs change:

Range("AD3").Select
Selection.AutoFill Destination:=Range("AD3:AD161"),Type:=xlFillDefaul t

I do not want the range AD3:AD161 to be fixed, as the no. of rows will keep changing.

Please help with both the doubts!
Thanks
Ashu

 
Old July 31st, 2004, 03:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The AutoFill method will change the value in all cells of the range.

If only cells which already have a value should be changed, loop through the range and determine if the cell is not empty before writing a new value.

This is an AutoFill ex:

Dim Rw As Long
Dim SourceRng As Range
Dim TargetRng As Range

Set SourceRng = ActiveSheet.Range("AD3")
Rw = Range("AD65536").End(xlUp).Row
Set TargetRng = ActiveSheet.Range("AD3:AD" & Rw)
SourceRng.AutoFill Destination:=TargetRng





Similar Threads
Thread Thread Starter Forum Replies Last Post
access function in data sheet(another sheet) jani Excel VBA 1 May 21st, 2008 07:15 PM
how to determine if there is existing data knightneo PHP Databases 2 December 3rd, 2006 01:35 AM
Counting Number of Rows Between Data Range eusanpe Excel VBA 6 September 21st, 2006 07:17 AM
disoplaying number of rows. ashokparchuri ADO.NET 2 April 21st, 2005 04:28 AM
How to determine cube root of a number... kaizer BOOK: Beginning Java 2 9 January 30th, 2004 12:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.