Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Real Value of .UsedRange.Rows.Count | Excel Worksheet Functions | |||
SpecialCells and UsedRange | Excel Programming | |||
UsedRange problem | Excel Programming | |||
UsedRange problem | Excel Programming | |||
Usedrange | Excel Programming |