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 can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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,223,649
Messages
6,173,580
Members
452,521
Latest member
bdough27

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