View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default "Object Required"

First problem is that there is no "zero-eth" character of a string of text.
So the first time you try to get Mid(txtBankName,Counter,1) you are hitting a
wall.

Solution to that is to either initialize Counter to 1 before beginning the
loop, or to move the Counter=Counter+1 up ahead of the ActiveCell.Offset(...
statement.

Also, if Counter is just a variable used in the code, get rid of the .Value
part of Counter.Value = 0 (or use Counter=1 if you decide on that fix here).

When referencing controls on a user form, if you want to be very specific
about it, you can use a reference like Me!txtBankName



"BOBODD" wrote:

As a newbie to VBA coding, I'm still strugling with the syntax. The loop
below is to fill in bank forms where each letter is in a seperate box.

Counter.Value = 0
Do
If Counter < 24 Then
ActiveCell.Offset(0, Counter) = Mid(txtBankName, Counter, 1)
Counter = Counter + 1
End If
Loop Until Counter = 24

I can't work out how to reference my counter so that the offset and the
letter change with each iteration. Any help would be appreciated.