VBA Single-Lettered Variables

Vathana

New Member
Joined
Jun 5, 2020
Messages
13
Office Version
  1. 2019
Platform
  1. Windows
Hello all.

Weird question? But is it safe to name variables with one letter only (A to Z)? I've seen "I" and "J" often in examples on the webs and used those myself too, but I'm afraid ones of the letters are VBA keywords.

Thanks.
 
Yeah same here. I've always wondered why "I" and "J" are used so often in loops :LOL:
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
My guess is that i was originally just short for integer & if you needed a 2nd loop you just used the next letter. ?‍♂️
I usually i for the counter unless It's for a 2D array in which case i use r & c.
 
Upvote 0
Single letter variables can make debug difficult. Multiletter variables can use camelcase so at coding time you have a prompt feedback about what you are writing.
 
Upvote 0

Forum statistics

Threads
1,225,384
Messages
6,184,643
Members
453,250
Latest member
unluckyuser

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