+ Reply to Thread
Results 1 to 4 of 4

Filling Cells from Textboxes

  1. #1
    trini
    Guest

    Filling Cells from Textboxes

    Hi everyone,
    I am trying to fill about 12 cells from 12 textboxes and for some reason my
    code does not work. I know it has to do with the 'Textboxi.Value' but how
    else can I do this?

    Dim i As Integer
    For i = 4 To 15
    emptyCell2.Offset(0, i) = TextBoxi.Value
    Next i

  2. #2
    Harald Staff
    Guest

    Re: Filling Cells from Textboxes

    Hi

    There is no textbox collection like that anymore. You are better off with
    long boring code like

    emptyCell2.Offset(0, 4).Value = TextBox4.Text
    emptyCell2.Offset(0, 5).Value = TextBox5.Text
    emptyCell2.Offset(0, 6).Value = TextBox6.Text
    emptyCell2.Offset(0, 7).Value = TextBox7.Text
    emptyCell2.Offset(0, 8).Value = TextBox8.Text
    ' and so on

    no fun to write, but runs fast and no-nonsense, and once it's written it's
    done. Any loop technique will be either slower, more awkward to execute or
    more memory consuming. A high price for a little less coding.

    HTH. Best wishes Harald

    "trini" <trini@discussions.microsoft.com> skrev i melding
    news:F649F203-FA75-42DE-9251-8B7F3DBBB59A@microsoft.com...
    > Hi everyone,
    > I am trying to fill about 12 cells from 12 textboxes and for some reason

    my
    > code does not work. I know it has to do with the 'Textboxi.Value' but how
    > else can I do this?
    >
    > Dim i As Integer
    > For i = 4 To 15
    > emptyCell2.Offset(0, i) = TextBoxi.Value
    > Next i




  3. #3
    Tonhao
    Guest

    RE: Filling Cells from Textboxes

    -> Try This
    Dim i As Integer
    Cells(2,4).Select ' Root Cell
    For i = 4 To 15
    Cells(ActiveCell.Row, i) = UserForm.Controls("TextBox" & i).Value
    Next i
    "trini" wrote:

    > Hi everyone,
    > I am trying to fill about 12 cells from 12 textboxes and for some reason my
    > code does not work. I know it has to do with the 'Textboxi.Value' but how
    > else can I do this?
    >
    > Dim i As Integer
    > For i = 4 To 15
    > emptyCell2.Offset(0, i) = TextBoxi.Value
    > Next i


  4. #4
    trini
    Guest

    Re: Filling Cells from Textboxes

    Thank you both for your response.

    "Harald Staff" wrote:

    > Hi
    >
    > There is no textbox collection like that anymore. You are better off with
    > long boring code like
    >
    > emptyCell2.Offset(0, 4).Value = TextBox4.Text
    > emptyCell2.Offset(0, 5).Value = TextBox5.Text
    > emptyCell2.Offset(0, 6).Value = TextBox6.Text
    > emptyCell2.Offset(0, 7).Value = TextBox7.Text
    > emptyCell2.Offset(0, 8).Value = TextBox8.Text
    > ' and so on
    >
    > no fun to write, but runs fast and no-nonsense, and once it's written it's
    > done. Any loop technique will be either slower, more awkward to execute or
    > more memory consuming. A high price for a little less coding.
    >
    > HTH. Best wishes Harald
    >
    > "trini" <trini@discussions.microsoft.com> skrev i melding
    > news:F649F203-FA75-42DE-9251-8B7F3DBBB59A@microsoft.com...
    > > Hi everyone,
    > > I am trying to fill about 12 cells from 12 textboxes and for some reason

    > my
    > > code does not work. I know it has to do with the 'Textboxi.Value' but how
    > > else can I do this?
    > >
    > > Dim i As Integer
    > > For i = 4 To 15
    > > emptyCell2.Offset(0, i) = TextBoxi.Value
    > > Next i

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1