Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Row in Column not working
OK, I am stuck. I have this line of code that was working:
Doesn't work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, "A").End(xlUp).Row Does work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row Now it only works if I replace the "A" with a 1. This is happening throughout my code where I do not use a column number. Anyone have any suggestions? thanks Terry |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Row in Column not working
Just a guess...
Perhaps Tools - Options - General tab; is the R1C1 reference style checked? In R1C1 reference style, both rows and columns are numbered numerically. "Terry" wrote: OK, I am stuck. I have this line of code that was working: Doesn't work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, "A").End(xlUp).Row Does work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row Now it only works if I replace the "A" with a 1. This is happening throughout my code where I do not use a column number. Anyone have any suggestions? thanks Terry |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Row in Column not working
I don't see where xlSheet is defined. If "xlSheet" is the name of a specific
worksheet (tab name) then: Sub ordinate() Dim ws As Worksheet Set ws = Sheets("xlSheet") MsgBox (ws.Cells(Rows.Count, "A").End(xlUp).Row) MsgBox (ws.Cells(Rows.Count, 1).End(xlUp).Row) End Sub -- Gary''s Student - gsnu200747 "Terry" wrote: OK, I am stuck. I have this line of code that was working: Doesn't work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, "A").End(xlUp).Row Does work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row Now it only works if I replace the "A" with a 1. This is happening throughout my code where I do not use a column number. Anyone have any suggestions? thanks Terry |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Row in Column not working
This worked just not the way I expected. Somehow the file had been
corrupted. By checking the R1C1 box it forced me to correct the corrupted names. When unchecking the box it prompted me to correct a few more. When done my code worked as before. Thanks for your help. Terry "cottage6" wrote: Just a guess... Perhaps Tools - Options - General tab; is the R1C1 reference style checked? In R1C1 reference style, both rows and columns are numbered numerically. "Terry" wrote: OK, I am stuck. I have this line of code that was working: Doesn't work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, "A").End(xlUp).Row Does work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row Now it only works if I replace the "A" with a 1. This is happening throughout my code where I do not use a column number. Anyone have any suggestions? thanks Terry |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Last Row in Column not working
Sorry Gary;
I only put the line of code with the error. I had everything defined similiar to what you have. Not sure why but I had some corrupt chart/graph names that were causing the error. By checking and unchecking the R1C1 box it forced me to rename all the problems. Works now as before. thanks Terry "Gary''s Student" wrote: I don't see where xlSheet is defined. If "xlSheet" is the name of a specific worksheet (tab name) then: Sub ordinate() Dim ws As Worksheet Set ws = Sheets("xlSheet") MsgBox (ws.Cells(Rows.Count, "A").End(xlUp).Row) MsgBox (ws.Cells(Rows.Count, 1).End(xlUp).Row) End Sub -- Gary''s Student - gsnu200747 "Terry" wrote: OK, I am stuck. I have this line of code that was working: Doesn't work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, "A").End(xlUp).Row Does work lnglastrow = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row Now it only works if I replace the "A" with a 1. This is happening throughout my code where I do not use a column number. Anyone have any suggestions? thanks Terry |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sort Not Working on Column of Numbers | Excel Worksheet Functions | |||
Trying to transpose a row to a column - it is not working - help! | Excel Worksheet Functions | |||
Printing after using column auto fit - not working | Excel Discussion (Misc queries) | |||
Working out first and last column and row in a range | Excel Programming | |||
working by column name | Excel Programming |