Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with UsedRange.Rows.Count

Hi,

I use this command to know what will be the next row to use to save th
data of the invoice I just printed. The data of every invoice is sav
on one line of the data sheet.

The problem is that if my DATA sheet is empty, no line used, th
command UsedRange.Rows.Count will return 1.

If one line is used, it will also return 1.

To go around this problem, I put a dummy in the first row. But I don'
like it.

Any idea on how to fix my problem ? Is there a way to hav
UsedRange.Rows.Count return 0 when no line are used?

Thanks!

Alai

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Problem with UsedRange.Rows.Count

Add a line to check a cell to see if it is empty (""), If your UsedRange
count is 1. If it is empty, then count is 0.

X= ActiveSheet.UsedRange.Rows.Count
If X = 1 AND Range("A1").Value = "" Then X + 0

MIke F

"alainB " wrote in message
...
Hi,

I use this command to know what will be the next row to use to save the
data of the invoice I just printed. The data of every invoice is save
on one line of the data sheet.

The problem is that if my DATA sheet is empty, no line used, the
command UsedRange.Rows.Count will return 1.

If one line is used, it will also return 1.

To go around this problem, I put a dummy in the first row. But I don't
like it.

Any idea on how to fix my problem ? Is there a way to have
UsedRange.Rows.Count return 0 when no line are used?

Thanks!

Alain


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Problem with UsedRange.Rows.Count

Sorry, I mis-typed, the last line should be

X= ActiveSheet.UsedRange.Rows.Count
If X = 1 AND Range("A1").Value = "" Then X = 0

MIke F

"Mike Fogleman" wrote in message
news:yW5kc.44601$cF6.1875944@attbi_s04...
Add a line to check a cell to see if it is empty (""), If your UsedRange
count is 1. If it is empty, then count is 0.

X= ActiveSheet.UsedRange.Rows.Count
If X = 1 AND Range("A1").Value = "" Then X + 0

MIke F

"alainB " wrote in message
...
Hi,

I use this command to know what will be the next row to use to save the
data of the invoice I just printed. The data of every invoice is save
on one line of the data sheet.

The problem is that if my DATA sheet is empty, no line used, the
command UsedRange.Rows.Count will return 1.

If one line is used, it will also return 1.

To go around this problem, I put a dummy in the first row. But I don't
like it.

Any idea on how to fix my problem ? Is there a way to have
UsedRange.Rows.Count return 0 when no line are used?

Thanks!

Alain


---
Message posted from http://www.ExcelForum.com/





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Problem with UsedRange.Rows.Count

Hi

Use this function in a module.

The UsedRange will not always give you the last row with Data
See Debra's site for this
http://www.contextures.com/xlfaqApp.html#Unused


Sub test()
MsgBox LRow(ActiveSheet) + 1
End Sub

Function LRow(sh As Worksheet)
On Error Resume Next
LRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function



--
Regards Ron de Bruin
http://www.rondebruin.nl


"alainB " wrote in message ...
Hi,

I use this command to know what will be the next row to use to save the
data of the invoice I just printed. The data of every invoice is save
on one line of the data sheet.

The problem is that if my DATA sheet is empty, no line used, the
command UsedRange.Rows.Count will return 1.

If one line is used, it will also return 1.

To go around this problem, I put a dummy in the first row. But I don't
like it.

Any idea on how to fix my problem ? Is there a way to have
UsedRange.Rows.Count return 0 when no line are used?

Thanks!

Alain


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with UsedRange.Rows.Count

Thank you very much Ron!

I used your code and it is working fine.

I don't really understand it (the code)...but it is working!!

Thanks again!

Alai

--
Message posted from http://www.ExcelForum.com

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
Real Value of .UsedRange.Rows.Count dazman Excel Worksheet Functions 2 August 25th 05 03:24 PM
SpecialCells and UsedRange Norm[_5_] Excel Programming 2 April 1st 04 06:53 PM
UsedRange problem Kobayashi[_26_] Excel Programming 4 January 30th 04 06:17 PM
UsedRange problem Andy Excel Programming 2 September 18th 03 05:17 PM
Usedrange Terry VanDuzee Excel Programming 6 August 10th 03 05:57 PM


All times are GMT +1. The time now is 11:39 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"