View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default The most basic question ever - what does "i" mean

i is a variable. The name was Bill's choice--almost arbitrary. He wouldn't use
a variable named Long, Integer, Row, Font, Bold or any thing built into excel's
VBA--or any illegal name (VBA's help will explain more).

In this case, I bet Bill has a line like:
Dim i As Long
(or "Dim i as integer")
in his code

In this case, it's a place holder that he can use for looping between the number
1 and the number that's stored in that FinalRow (another variable).

So for the first time through (when i = 1):
Range ("A" & 1 & ":E" & 1).Font.Bold = True
which is:
Range ("A1":E1").Font.Bold = True

The 2nd time through, i = 2:
Range ("A" & 2 & ":E" & 2).Font.Bold = True
which is:
Range ("A2":E2").Font.Bold = True

If he had 1000 rows to bold, it would be very ugly to use 1000 lines like:

Range ("A1":E1").Font.Bold = True
Range ("A2":E2").Font.Bold = True
Range ("A3":E3").Font.Bold = True
Range ("A4":E4").Font.Bold = True
...
Range ("A1000":E1000").Font.Bold = True


jknapp1005 wrote:

Bill Jelen wrote a book for VBA in Excel 2007. I guess he thinks I know
everything. He is writing things and not explaining what they are. All the
sudden he's writing section of macros that say things like:

FinalRow = Cells(Rows.Count, 1). End(xlUp).Row
For i = 1 to FinalRow
Range ("A" & i & ":E" & i).Font.Bold = True
Next i

without explaining what the heck "i" means. Try searching for the meaning of
"i" in any database.


--

Dave Peterson