Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 193
Default 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
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
Sort Not Working on Column of Numbers therube Excel Worksheet Functions 4 February 9th 09 01:45 PM
Trying to transpose a row to a column - it is not working - help! MRAWLS Excel Worksheet Functions 4 December 10th 08 03:14 PM
Printing after using column auto fit - not working Caroline Lackey Excel Discussion (Misc queries) 2 June 9th 05 04:50 PM
Working out first and last column and row in a range Peter Rooney Excel Programming 6 April 28th 05 02:22 PM
working by column name Bryan[_11_] Excel Programming 1 August 15th 04 08:37 PM


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