PC Review


Reply
Thread Tools Rate Thread

Array problems

 
 
KneeDown2Up
Guest
Posts: n/a
 
      19th Feb 2008
I have a number of text boxes (ibox1 - ibox28) all holding data inputed via a
userform. To capture this data I potentially (with my knowledge) need this;


Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
...and so on.

I would like to be able to run this within a 'For/Next' loop but keep coming
up against problems.

For i = 1 to 28
Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox(i).Value
next i

Why is this? What can I do to make this principle work?

Any help appreciated, thanks.
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      19th Feb 2008
First of all, I am assuming you made a typo with:

Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value

and the second line should have been

Sheet19.Cells(6, c) = Sheet19.Cells(6, c) + ibox2.Value

If so, this should work:

For i = 1 to 28
Sheet19.Cells(i + 4, c) = Sheet19.Cells(i + 4, c) + ibox(i).Value
next i


"KneeDown2Up" wrote:

> I have a number of text boxes (ibox1 - ibox28) all holding data inputed via a
> userform. To capture this data I potentially (with my knowledge) need this;
>
>
> Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
> ..and so on.
>
> I would like to be able to run this within a 'For/Next' loop but keep coming
> up against problems.
>
> For i = 1 to 28
> Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox(i).Value
> next i
>
> Why is this? What can I do to make this principle work?
>
> Any help appreciated, thanks.

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      19th Feb 2008
For i = 1 To 10
Set bx = ActiveSheet.OLEObjects("TextBox" & i)
TextData = bx.Object.Text
Next i

"KneeDown2Up" wrote:

> I have a number of text boxes (ibox1 - ibox28) all holding data inputed via a
> userform. To capture this data I potentially (with my knowledge) need this;
>
>
> Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
> ..and so on.
>
> I would like to be able to run this within a 'For/Next' loop but keep coming
> up against problems.
>
> For i = 1 to 28
> Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox(i).Value
> next i
>
> Why is this? What can I do to make this principle work?
>
> Any help appreciated, thanks.

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      19th Feb 2008
Should be: For i = 1 to 28
Sheet19.Cells(i + 4, c) = Sheet19.Cells(i + 4, c) +
(ibox & i).Value
next i


"JLGWhiz" wrote:

> First of all, I am assuming you made a typo with:
>
> Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
>
> and the second line should have been
>
> Sheet19.Cells(6, c) = Sheet19.Cells(6, c) + ibox2.Value
>
> If so, this should work:
>
> For i = 1 to 28
> Sheet19.Cells(i + 4, c) = Sheet19.Cells(i + 4, c) + ibox (i).Value
> next i
>
>
> "KneeDown2Up" wrote:
>
> > I have a number of text boxes (ibox1 - ibox28) all holding data inputed via a
> > userform. To capture this data I potentially (with my knowledge) need this;
> >
> >
> > Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> > Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
> > ..and so on.
> >
> > I would like to be able to run this within a 'For/Next' loop but keep coming
> > up against problems.
> >
> > For i = 1 to 28
> > Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox(i).Value
> > next i
> >
> > Why is this? What can I do to make this principle work?
> >
> > Any help appreciated, thanks.

 
Reply With Quote
 
KneeDown2Up
Guest
Posts: n/a
 
      20th Feb 2008
Thanks JL - nearly there although I can't quite get this to work. It would
seem the ibox variable isn't carrying the value entered by the user. It just
inputs 1 - 28 (on each loop) and the ibox is empty. When I put the .value to
the ibox it comes up with an 'expected: end of statement' message. I tried
declaring each of the iboxes (ibox1, ibox2) etc in the 'Declarations' part
but to no avail (another error message).

"JLGWhiz" wrote:

> Should be: For i = 1 to 28
> Sheet19.Cells(i + 4, c) = Sheet19.Cells(i + 4, c) +
> (ibox & i).Value
> next i
>
>
> "JLGWhiz" wrote:
>
> > First of all, I am assuming you made a typo with:
> >
> > Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> > Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
> >
> > and the second line should have been
> >
> > Sheet19.Cells(6, c) = Sheet19.Cells(6, c) + ibox2.Value
> >
> > If so, this should work:
> >
> > For i = 1 to 28
> > Sheet19.Cells(i + 4, c) = Sheet19.Cells(i + 4, c) + ibox (i).Value
> > next i
> >
> >
> > "KneeDown2Up" wrote:
> >
> > > I have a number of text boxes (ibox1 - ibox28) all holding data inputed via a
> > > userform. To capture this data I potentially (with my knowledge) need this;
> > >
> > >
> > > Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox1.Value
> > > Sheet19.Cells(6, c) = Sheet19.Cells(5, c) + ibox2.Value
> > > ..and so on.
> > >
> > > I would like to be able to run this within a 'For/Next' loop but keep coming
> > > up against problems.
> > >
> > > For i = 1 to 28
> > > Sheet19.Cells(5, c) = Sheet19.Cells(5, c) + ibox(i).Value
> > > next i
> > >
> > > Why is this? What can I do to make this principle work?
> > >
> > > Any help appreciated, thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Loading Large String Array into Array variable ExcelMonkey Microsoft Excel Programming 6 6th May 2009 11:20 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
Problems with Array systemx Microsoft Excel Programming 1 20th Dec 2005 01:42 PM
Problems Converting 1-D Array to 2-D Array ExcelMonkey Microsoft Excel Programming 1 28th Mar 2005 12:16 AM
Array Problems MikeC Microsoft Access VBA Modules 2 14th Feb 2005 09:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:37 PM.