Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Need VBA code to dtermine how many rows have data in them

I need to determine how many rows contain data so that i know when to
stop a loop.

Also is there an or statement in VBA?

for example

If Cells(Rowx, Coly) Like "*cats*" or Cells(Rowx, Coly) Like "*dogs*"
The
....

I am new to VBA and truly appreciate your help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Need VBA code to dtermine how many rows have data in them

Here is a good way.

dim i as integer
dim x as integer

x = ActiveSheet.UsedRange.Rows.Count

for i=1 to x
'insert loop code here
next i

or, if you wanted to select the next available free cell in a column,
you could use

x = ActiveSheet.UsedRange.Rows.Count
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.EntireRow.Cells(1, 1).Offset(1, 0).Select

This would select the first cell in column 1 that was free right below
the last used row.
Obviously, you can alter cells(x,x) or the offset(x,x) to fit your
needs.

joran6

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Need VBA code to dtermine how many rows have data in them

A convenient way to find rows in a list of data is the .CurrentRegion
property, e.g. Range("A1").CurrentRegion.Rows.Count gives the number of rows
in the rectangular region including all contiguous used cells starting in
cell A1.

For the "or", yes there is a VBA way to do it and it is straightforward: in
fact, you have it correct!
--
- K Dales


"Shani" wrote:

I need to determine how many rows contain data so that i know when to
stop a loop.

Also is there an or statement in VBA?

for example

If Cells(Rowx, Coly) Like "*cats*" or Cells(Rowx, Coly) Like "*dogs*"
The
....

I am new to VBA and truly appreciate your help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Need VBA code to dtermine how many rows have data in them

Thank you guys you were very helpful

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Need VBA code to dtermine how many rows have data in them

Thank you guys you were very helpful



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code to hide rows and not calculate hidden rows bradmcq Excel Discussion (Misc queries) 0 September 1st 09 12:38 AM
Enabling option „Format rows“ to hide/unhide rows using VBA-code? ran58 Excel Discussion (Misc queries) 0 July 28th 09 03:46 PM
VBA Code Required to Get Data Which is In Coloums Into Rows stublair Excel Programming 2 December 16th 05 04:35 PM
VBA code to add rows Kiran Excel Discussion (Misc queries) 4 July 12th 05 07:57 PM


All times are GMT +1. The time now is 06:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"