+ Reply to Thread
Results 1 to 2 of 2

Collecting textbox input within a for loop

Hybrid View

  1. #1

    Collecting textbox input within a for loop

    I am attempting to collect textbox input within a for loop in Sheet1.
    It does not stop on the activate and just zooms through the for loop
    without prompting for the field. Then it should transfer the data which
    was input to a range in Sheet2. Anyone who can tell me what is wrong?

    Thanks so much.
    -Michael

    ------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Workbook_Open()

    Dim OLEObj As OLEObject
    Dim iCtr As Long
    Dim CellToCheck, Cell2ToCheck, CellToGet, Cell2ToGet As Range


    Set CellToGet = Sheet2.Range("d1")


    ' gather initial 4 textboxes

    For iCtr = 1 To 4
    Set OLEObj = Sheet1.OLEObjects("TextBox" & iCtr)
    OLEObj.Activate
    With OLEObj.Object
    CellToGet.Value = .Value
    End With
    'dropdown one row for the next text box
    Set CellToGet = CellToGet.Offset(1, 0)

    Next iCtr

    End Sub


  2. #2
    Rick Hansen
    Guest

    Re: Collecting textbox input within a for loop

    Mike, Your code is doing exactly what your telling it to do. The Activate
    method only select the object, but will not stop the code from executing.
    Maybe you can try the InputBox function...

    enjoy, Rick


    <[email protected]> wrote in message
    news:[email protected]...
    > I am attempting to collect textbox input within a for loop in Sheet1.
    > It does not stop on the activate and just zooms through the for loop
    > without prompting for the field. Then it should transfer the data which
    > was input to a range in Sheet2. Anyone who can tell me what is wrong?
    >
    > Thanks so much.
    > -Michael
    >
    > --------------------------------------------------------------------------

    ----------------------------------------------------------
    >
    > Private Sub Workbook_Open()
    >
    > Dim OLEObj As OLEObject
    > Dim iCtr As Long
    > Dim CellToCheck, Cell2ToCheck, CellToGet, Cell2ToGet As Range
    >
    >
    > Set CellToGet = Sheet2.Range("d1")
    >
    >
    > ' gather initial 4 textboxes
    >
    > For iCtr = 1 To 4
    > Set OLEObj = Sheet1.OLEObjects("TextBox" & iCtr)
    > OLEObj.Activate
    > With OLEObj.Object
    > CellToGet.Value = .Value
    > End With
    > 'dropdown one row for the next text box
    > Set CellToGet = CellToGet.Offset(1, 0)
    >
    > Next iCtr
    >
    > End Sub
    >




+ 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