Why would i need a row reference, when i only want to find the last column?
Because you need to construct a valid range reference that accurately reflects what you want.
If you wanted to use "Range" and only have a column reference, it would need to look something like this:
But look what you are building:
Columns.Count returns 16384.
So this:
VBA Code:
lc = Range("a" & Columns.Count).End(xlToLeft).Column
would translate to this:
VBA Code:
lc = Range("A16384").End(xlToLeft).Column
which is actually column A, row 16384.
Since you are already starting in column A, you cannot move any further to the left, so this will ALWAYS return column 1.
So if specify row, that is A1
lc = Range("a1" & Columns.Count).End(xlToLeft).Column
Also doesn't work, gives me last column is 1
Not able to clearly understand
Once again, use like the previous one, Columns.Count will return 16384.
So by concatenating on "A1" in front of that reference, you now have:
VBA Code:
lc = Range("A116384").End(xlToLeft).Column
which is column A, row 116384.
And just like the previous explanation, since you are starting in column A, you cannot move any further to the left and will always return column 1.
When you cannot figure things like this out, the best thing to do is start subtituting the values like I showed above to see what you are really building.
Also note when using "Range" in referencing ranges, the column reference HAS to be a letter, it cannot be a number. That is very limiting, and makes it hard to get the last column reference using this method.
However, using "Cells", you can refer to the column by the letter or by the numeric reference (i.e. "A"=1, "B"=2, "C"=3,...).
This gives you much more flexibility, and allows you to find the last column with data in a row, using the method show in your 3rd item in your original post.
Hope that clarifies things for you.