Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default "Object Required"

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default "Object Required"

dim i as long

for i=1 to 24
ActiveCell.Offset(0, i-1).value = Mid(txtBankName, i, 1)
next i

Tim

"BOBODD" wrote in message
...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default "Object Required"

If you want the first letter of whatever is in txtBankName to be in the
active cell (column offset 0) then try this
Counter=0
Do
If Counter<24 Then
ActiveCell.Offset(0,Counter)=Mid(txtBankName,Count er+1, 1)
Counter=Counter+1
End If
Loop Until Counter = 24

"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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
"Microsoft Visual Basic runtime error '424' object required". SharonG. Excel Worksheet Functions 0 July 5th 06 01:36 AM
error while compiling "OBJECT REQUIRED" nuti Excel Discussion (Misc queries) 1 January 12th 06 03:14 PM
Getting "Object Required" Error Message - Need Help !!! [email protected] Excel Programming 3 November 22nd 04 02:53 PM
update...."object required" rt er 424 Kenny Excel Programming 2 December 5th 03 01:29 AM


All times are GMT +1. The time now is 09:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"