Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error | Excel Discussion (Misc queries) | |||
"Microsoft Visual Basic runtime error '424' object required". | Excel Worksheet Functions | |||
error while compiling "OBJECT REQUIRED" | Excel Discussion (Misc queries) | |||
Getting "Object Required" Error Message - Need Help !!! | Excel Programming | |||
update...."object required" rt er 424 | Excel Programming |