Last Row in Column not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
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
 
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
 
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
 
Back
Top