ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with UsedRange.Rows.Count (https://www.excelbanter.com/excel-programming/296699-problem-usedrange-rows-count.html)

alainB[_15_]

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


Mike Fogleman

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/




Mike Fogleman

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/






Ron de Bruin

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/




alainB[_16_]

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



All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com