Range and numbers

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,072
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I found this here
Anything that you can do with a column letter, you can do with a column #.
It's often easier to work with that number anyway.
There is very rarely a need to actually convert a number to column letter.
Other than for visual representation, so you can say to a user/student/boss or something "See, it's in column X"
But Excel doesn't 'need' it.

and applied this logic. But now I'm a bit stuck I have (example) .range("J2")
How is range expressed with numbers only ? Or should I use .cells(2,9) ?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I have (example) .range("J2")
How is range expressed with numbers only ? Or should I use .cells(2,9) ?
.. except of course it would be .cells(2,10) for J2 if it was qualified to a worksheet. ;)
 
Upvote 0
It's often easier to work with that number anyway.
It depends on each programmer, you get used to using letters or numbers. In my case I prefer to use letters.


There is very rarely a need to actually convert a number to column letter.
It is often necessary to convert column numbers to column letters when you use letters in formulas, examples:
VBA code to multiply many rows with some conditions
count without duplicate
Now I can't find examples of converting number to letter, but the idea is that it is easier to work with letters when it comes to putting the formulas in vba.

Other than for visual representation, so you can say to a user/student/boss or something "See, it's in column X"
But Excel doesn't 'need' it.
An advantage of using Range instead of Cell, with Range you can access the VBA intellisense that will show you the properties or methods of the object:

1724561700105.png


and applied this logic. But now I'm a bit stuck I have (example) .range("J2")
How is range expressed with numbers only ? Or should I use .cells(2,9) ?
Then, .Range("J2") is equivalent to .Cells(2, 10)
You can even use .Cells(2, "J")

Or a combination of both, you could have numbers and access to vba intellisense:
VBA Code:
.Range(.Cells(2, 10).Address)
1724562238518.png



;)
 

Attachments

  • 1724562128430.png
    1724562128430.png
    7.8 KB · Views: 1
Upvote 0
If you use FormulaR1C1 (or local equivalent) then column numbers can be used without having to convert to letters.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top