Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Used range row count throwing up a wierd result, slects wrong as well!

Hi, this is a strange one...the following items reside in column 1 from rwos
1 to 10:

Local cash
Local bond
Local equity
Local property
Foreign currency
Foreign bonds
Foreign Equity
Foreigh property
Alternative
Commodity


My code wants the number of items (i.e. the number of non empty rows:

bNoItems = Sheets(sSheetName & "_Items").UsedRange.Rows.Count

Answer comes back 13 not 10! Also when I try and select it it selects 3
empty cells on the end (aty least it's consistent!). Anyone any idea what
may be wrong/with a better way of achieving the count, thanks, Mark


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Used range row count throwing up a wierd result, slects wrong as well!

Usedrange has a known bug in that it holds on to previous values. See
http://www.contextures.com/xlfaqApp.html#Unused

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Mark Stephens" wrote in message
...
Hi, this is a strange one...the following items reside in column 1 from
rwos 1 to 10:

Local cash
Local bond
Local equity
Local property
Foreign currency
Foreign bonds
Foreign Equity
Foreigh property
Alternative
Commodity


My code wants the number of items (i.e. the number of non empty rows:

bNoItems = Sheets(sSheetName & "_Items").UsedRange.Rows.Count

Answer comes back 13 not 10! Also when I try and select it it selects 3
empty cells on the end (aty least it's consistent!). Anyone any idea what
may be wrong/with a better way of achieving the count, thanks, Mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
bst bst is offline
external usenet poster
 
Posts: 19
Default Used range row count throwing up a wierd result, slects wrong as well!

one way i would count nonempty cells if the usedrange method is
unreliable:

counter = 1
do while isempty(.cell(counter,1).value)
counter = counter +1
end loop

the counter variable should now give you an accurate number of cells
that are not empty. this is assuming there are no empty cells inbetween
the cells that contain data

hth
bst

"Mark Stephens" wrote in
:


Hi, this is a strange one...the following items reside in column 1
from rwos 1 to 10:

Local cash
Local bond
Local equity
Local property
Foreign currency
Foreign bonds
Foreign Equity
Foreigh property
Alternative
Commodity


My code wants the number of items (i.e. the number of non empty rows:

bNoItems = Sheets(sSheetName & "_Items").UsedRange.Rows.Count

Answer comes back 13 not 10! Also when I try and select it it selects
3 empty cells on the end (aty least it's consistent!). Anyone any idea
what may be wrong/with a better way of achieving the count, thanks,
Mark



  #4   Report Post  
Posted to microsoft.public.excel.programming
bst bst is offline
external usenet poster
 
Posts: 19
Default Used range row count throwing up a wierd result, slects wrong as well!

the code below should read not isempty.

sorry for the mistake

bst
bst wrote in news:Xns9ACF87B432CC6nonenonecom@
140.99.99.130:

one way i would count nonempty cells if the usedrange method is
unreliable:

counter = 1
do while isempty(.cell(counter,1).value)
counter = counter +1
end loop

the counter variable should now give you an accurate number of cells
that are not empty. this is assuming there are no empty cells

inbetween
the cells that contain data

hth
bst

"Mark Stephens" wrote in
:


Hi, this is a strange one...the following items reside in column 1
from rwos 1 to 10:

Local cash
Local bond
Local equity
Local property
Foreign currency
Foreign bonds
Foreign Equity
Foreigh property
Alternative
Commodity


My code wants the number of items (i.e. the number of non empty rows:

bNoItems = Sheets(sSheetName & "_Items").UsedRange.Rows.Count

Answer comes back 13 not 10! Also when I try and select it it selects
3 empty cells on the end (aty least it's consistent!). Anyone any

idea
what may be wrong/with a better way of achieving the count, thanks,
Mark





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Used range row count throwing up a wierd result, slects wrong as well!

Thanks bst, that's the way I did it although I used a Do Loop which counts
the rows and exits when the row value is ""

Do

bRow = bRow + 1

If Sheets("DataEntry").Range("E" & bRow).Value = "" Then
pbNoFunds = bRow - 1
Exit Do
End if


Loop




Regards, Mark
"bst" wrote in message
...
one way i would count nonempty cells if the usedrange method is
unreliable:

counter = 1
do while isempty(.cell(counter,1).value)
counter = counter +1
end loop

the counter variable should now give you an accurate number of cells
that are not empty. this is assuming there are no empty cells inbetween
the cells that contain data

hth
bst

"Mark Stephens" wrote in
:


Hi, this is a strange one...the following items reside in column 1
from rwos 1 to 10:

Local cash
Local bond
Local equity
Local property
Foreign currency
Foreign bonds
Foreign Equity
Foreigh property
Alternative
Commodity


My code wants the number of items (i.e. the number of non empty rows:

bNoItems = Sheets(sSheetName & "_Items").UsedRange.Rows.Count

Answer comes back 13 not 10! Also when I try and select it it selects
3 empty cells on the end (aty least it's consistent!). Anyone any idea
what may be wrong/with a better way of achieving the count, thanks,
Mark







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
EXCEL VBA - Find Method or Range in IE throwing error Malik Excel Programming 3 March 30th 08 05:39 PM
excel result return wrong calcuation result garyww Excel Worksheet Functions 1 August 14th 06 11:14 AM
Wrong result returned by UsedRange.Rows.Count j[_4_] Excel Programming 3 June 20th 05 09:03 PM
Wierd conditional formatting result (oops pressed send to soon!) Paul Lautman Excel Programming 2 June 23rd 04 03:36 PM
Wierd conditional formatting result. Paul Lautman Excel Programming 1 June 21st 04 05:36 PM


All times are GMT +1. The time now is 09:18 AM.

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

About Us

"It's about Microsoft Excel"