View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default ActiveCell.Offset(i, 0) = Chr(ActiveCell.Row + 62) returns all A's

Howard expressed precisely :
Why won't subject line increment A B C D etc. in code. Should increment the
number of times as entered in InputBox but instead returns all A's below A3.

Option Explicit

Sub MakeRanger()
Dim CNum As String
Dim i As Long

CNum = InputBox(" Enter a number.", _
"a Number")

i = CNum

Range("A3").Select
For i = 1 To i - 1
ActiveCell.Offset(0, i) = i
ActiveCell.Offset(i, 0) = Chr(ActiveCell.Row + 62)
Next
End Sub

Thanks,
Howard


Howard,
Your cell of origin remains constant and so is always the ref for each
iteration of your loop. IOW, ActiveCell.Row+62 doesn't change the
character returned by Chr()! Thus every row will contain the same
character. You'll have to match the row offset so Chr() increments with
each row...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion