+ Reply to Thread
Results 1 to 6 of 6

what do I do wrong?

  1. #1
    antonov
    Guest

    what do I do wrong?

    ehmmm... a last question and hopefully I will be done with my sheet...
    My sheet contains 2 tables of 4 columns / 17 rows each
    The data for these tables SHOULD come from an userform (which I've already
    made). When the "ready" button in the userform is pushed the data should go
    in the first empty row (this is what I use for this purpose):

    Private Sub cmdNext_Click()
    ActiveWorkbook.Sheets("Sheet1").Activate
    Range("B16").Select
    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    End If
    Loop Until IsEmpty(ActiveCell) = True

    Next step is where everything goes wrong:

    now the data has to be input in the right place and this is what I do:

    ActiveCell.Value = txtCode1.Value
    ActiveCell.Offset(0, 1) = txtCode2.Value
    ActiveCell.Offset(0, 2) = txtDate.Value
    End sub

    Apparently this code is not working. All I get is the first line highlighted
    and that's it.

    Furthermore: when the first table is full (4 colums / 17 rows) I need the
    data to go to the next table which start at the same hight as the first (say
    row 16) but 7 columns to the right....

    Sorry for the lenght of this but english is not my language and I don't know
    how to keep it short...

    Thanks for any help....



  2. #2
    STEVE BELL
    Guest

    Re: what do I do wrong?

    Try something like this

    Dim lrw as long

    lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row

    If lrw < 16 then
    lrw = 16
    End If

    Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value

    --
    steveB

    Remove "AYN" from email to respond
    "antonov" <[email protected]> wrote in message
    news:[email protected]...
    > ehmmm... a last question and hopefully I will be done with my sheet...
    > My sheet contains 2 tables of 4 columns / 17 rows each
    > The data for these tables SHOULD come from an userform (which I've already
    > made). When the "ready" button in the userform is pushed the data should
    > go in the first empty row (this is what I use for this purpose):
    >
    > Private Sub cmdNext_Click()
    > ActiveWorkbook.Sheets("Sheet1").Activate
    > Range("B16").Select
    > Do
    > If IsEmpty(ActiveCell) = False Then
    > ActiveCell.Offset(1, 0).Select
    > End If
    > Loop Until IsEmpty(ActiveCell) = True
    >
    > Next step is where everything goes wrong:
    >
    > now the data has to be input in the right place and this is what I do:
    >
    > ActiveCell.Value = txtCode1.Value
    > ActiveCell.Offset(0, 1) = txtCode2.Value
    > ActiveCell.Offset(0, 2) = txtDate.Value
    > End sub
    >
    > Apparently this code is not working. All I get is the first line
    > highlighted and that's it.
    >
    > Furthermore: when the first table is full (4 colums / 17 rows) I need the
    > data to go to the next table which start at the same hight as the first
    > (say row 16) but 7 columns to the right....
    >
    > Sorry for the lenght of this but english is not my language and I don't
    > know how to keep it short...
    >
    > Thanks for any help....
    >
    >




  3. #3
    antonov
    Guest

    Re: what do I do wrong?

    Hello Steve...
    I've tried your option but I still get the same error... the line is
    highlighted and nothing happens
    "STEVE BELL" <[email protected]> wrote in message
    news:bkzEe.2457$uy3.1136@trnddc05...
    > Try something like this
    >
    > Dim lrw as long
    >
    > lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >
    > If lrw < 16 then
    > lrw = 16
    > End If
    >
    > Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    > Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    > Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    >
    > --
    > steveB
    >
    > Remove "AYN" from email to respond
    > "antonov" <[email protected]> wrote in message
    > news:[email protected]...
    >> ehmmm... a last question and hopefully I will be done with my sheet...
    >> My sheet contains 2 tables of 4 columns / 17 rows each
    >> The data for these tables SHOULD come from an userform (which I've
    >> already made). When the "ready" button in the userform is pushed the data
    >> should go in the first empty row (this is what I use for this purpose):
    >>
    >> Private Sub cmdNext_Click()
    >> ActiveWorkbook.Sheets("Sheet1").Activate
    >> Range("B16").Select
    >> Do
    >> If IsEmpty(ActiveCell) = False Then
    >> ActiveCell.Offset(1, 0).Select
    >> End If
    >> Loop Until IsEmpty(ActiveCell) = True
    >>
    >> Next step is where everything goes wrong:
    >>
    >> now the data has to be input in the right place and this is what I do:
    >>
    >> ActiveCell.Value = txtCode1.Value
    >> ActiveCell.Offset(0, 1) = txtCode2.Value
    >> ActiveCell.Offset(0, 2) = txtDate.Value
    >> End sub
    >>
    >> Apparently this code is not working. All I get is the first line
    >> highlighted and that's it.
    >>
    >> Furthermore: when the first table is full (4 colums / 17 rows) I need the
    >> data to go to the next table which start at the same hight as the first
    >> (say row 16) but 7 columns to the right....
    >>
    >> Sorry for the lenght of this but english is not my language and I don't
    >> know how to keep it short...
    >>
    >> Thanks for any help....
    >>
    >>

    >
    >




  4. #4
    STEVE BELL
    Guest

    Re: what do I do wrong?

    Does your code look like the below -
    If Yes than what line are you refering to.
    If No than replace your code with this.

    Make sure that all your references are correct and that the worksheet
    name is "Sheet1"

    Compile your code.

    Put a breakpoint at the first line: lrw = ...
    Call up the form and use F8 to step through the code
    Monitor the variable values and let me know where it stops.

    Private Sub cmdNext_Click()
    Dim lrw as long

    lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row

    If lrw < 16 then
    lrw = 16
    End If

    Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    End sub

    --
    steveB

    Remove "AYN" from email to respond
    "antonov" <[email protected]> wrote in message
    news:[email protected]...
    > Hello Steve...
    > I've tried your option but I still get the same error... the line is
    > highlighted and nothing happens
    > "STEVE BELL" <[email protected]> wrote in message
    > news:bkzEe.2457$uy3.1136@trnddc05...
    >> Try something like this
    >>
    >> Dim lrw as long
    >>
    >> lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >>
    >> If lrw < 16 then
    >> lrw = 16
    >> End If
    >>
    >> Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    >> Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    >> Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    >>
    >> --
    >> steveB
    >>
    >> Remove "AYN" from email to respond
    >> "antonov" <[email protected]> wrote in message
    >> news:[email protected]...
    >>> ehmmm... a last question and hopefully I will be done with my sheet...
    >>> My sheet contains 2 tables of 4 columns / 17 rows each
    >>> The data for these tables SHOULD come from an userform (which I've
    >>> already made). When the "ready" button in the userform is pushed the
    >>> data should go in the first empty row (this is what I use for this
    >>> purpose):
    >>>
    >>> Private Sub cmdNext_Click()
    >>> ActiveWorkbook.Sheets("Sheet1").Activate
    >>> Range("B16").Select
    >>> Do
    >>> If IsEmpty(ActiveCell) = False Then
    >>> ActiveCell.Offset(1, 0).Select
    >>> End If
    >>> Loop Until IsEmpty(ActiveCell) = True
    >>>
    >>> Next step is where everything goes wrong:
    >>>
    >>> now the data has to be input in the right place and this is what I do:
    >>>
    >>> ActiveCell.Value = txtCode1.Value
    >>> ActiveCell.Offset(0, 1) = txtCode2.Value
    >>> ActiveCell.Offset(0, 2) = txtDate.Value
    >>> End sub
    >>>
    >>> Apparently this code is not working. All I get is the first line
    >>> highlighted and that's it.
    >>>
    >>> Furthermore: when the first table is full (4 colums / 17 rows) I need
    >>> the data to go to the next table which start at the same hight as the
    >>> first (say row 16) but 7 columns to the right....
    >>>
    >>> Sorry for the lenght of this but english is not my language and I don't
    >>> know how to keep it short...
    >>>
    >>> Thanks for any help....
    >>>
    >>>

    >>
    >>

    >
    >




  5. #5
    antonov
    Guest

    Re: what do I do wrong?

    The code looks exactely like the one below (I've done copy & paste).
    It stops right here:
    Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    the error message is: Run-time error "424" object required

    "STEVE BELL" <[email protected]> wrote in message
    news:wAAEe.2469$uy3.775@trnddc05...
    > Does your code look like the below -
    > If Yes than what line are you refering to.
    > If No than replace your code with this.
    >
    > Make sure that all your references are correct and that the worksheet
    > name is "Sheet1"
    >
    > Compile your code.
    >
    > Put a breakpoint at the first line: lrw = ...
    > Call up the form and use F8 to step through the code
    > Monitor the variable values and let me know where it stops.
    >
    > Private Sub cmdNext_Click()
    > Dim lrw as long
    >
    > lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >
    > If lrw < 16 then
    > lrw = 16
    > End If
    >
    > Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    > Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    > Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    > End sub
    >
    > --
    > steveB
    >
    > Remove "AYN" from email to respond
    > "antonov" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hello Steve...
    >> I've tried your option but I still get the same error... the line is
    >> highlighted and nothing happens
    >> "STEVE BELL" <[email protected]> wrote in message
    >> news:bkzEe.2457$uy3.1136@trnddc05...
    >>> Try something like this
    >>>
    >>> Dim lrw as long
    >>>
    >>> lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >>>
    >>> If lrw < 16 then
    >>> lrw = 16
    >>> End If
    >>>
    >>> Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    >>> Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    >>> Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    >>>
    >>> --
    >>> steveB
    >>>
    >>> Remove "AYN" from email to respond
    >>> "antonov" <[email protected]> wrote in message
    >>> news:[email protected]...
    >>>> ehmmm... a last question and hopefully I will be done with my sheet...
    >>>> My sheet contains 2 tables of 4 columns / 17 rows each
    >>>> The data for these tables SHOULD come from an userform (which I've
    >>>> already made). When the "ready" button in the userform is pushed the
    >>>> data should go in the first empty row (this is what I use for this
    >>>> purpose):
    >>>>
    >>>> Private Sub cmdNext_Click()
    >>>> ActiveWorkbook.Sheets("Sheet1").Activate
    >>>> Range("B16").Select
    >>>> Do
    >>>> If IsEmpty(ActiveCell) = False Then
    >>>> ActiveCell.Offset(1, 0).Select
    >>>> End If
    >>>> Loop Until IsEmpty(ActiveCell) = True
    >>>>
    >>>> Next step is where everything goes wrong:
    >>>>
    >>>> now the data has to be input in the right place and this is what I do:
    >>>>
    >>>> ActiveCell.Value = txtCode1.Value
    >>>> ActiveCell.Offset(0, 1) = txtCode2.Value
    >>>> ActiveCell.Offset(0, 2) = txtDate.Value
    >>>> End sub
    >>>>
    >>>> Apparently this code is not working. All I get is the first line
    >>>> highlighted and that's it.
    >>>>
    >>>> Furthermore: when the first table is full (4 colums / 17 rows) I need
    >>>> the data to go to the next table which start at the same hight as the
    >>>> first (say row 16) but 7 columns to the right....
    >>>>
    >>>> Sorry for the lenght of this but english is not my language and I don't
    >>>> know how to keep it short...
    >>>>
    >>>> Thanks for any help....
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >




  6. #6
    STEVE BELL
    Guest

    Re: what do I do wrong?

    Is this code in the userform module?
    Is txtCode1 the Name of a text box?
    txtCode1 must be the name of an object, and it must have a .Value
    property.
    Is Sheet1 the actual tab name of the worksheet?

    The code is not recognizing one or both of these as objects. Double check.

    Also you might need to change the structure into something like
    With Worksheets("Sheet1")
    .Cells(lrw,2)=txtbox1.value
    end with

    --
    steveB

    Remove "AYN" from email to respond
    "antonov" <[email protected]> wrote in message
    news:n%[email protected]...
    > The code looks exactely like the one below (I've done copy & paste).
    > It stops right here:
    > Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    > the error message is: Run-time error "424" object required
    >
    > "STEVE BELL" <[email protected]> wrote in message
    > news:wAAEe.2469$uy3.775@trnddc05...
    >> Does your code look like the below -
    >> If Yes than what line are you refering to.
    >> If No than replace your code with this.
    >>
    >> Make sure that all your references are correct and that the worksheet
    >> name is "Sheet1"
    >>
    >> Compile your code.
    >>
    >> Put a breakpoint at the first line: lrw = ...
    >> Call up the form and use F8 to step through the code
    >> Monitor the variable values and let me know where it stops.
    >>
    >> Private Sub cmdNext_Click()
    >> Dim lrw as long
    >>
    >> lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >>
    >> If lrw < 16 then
    >> lrw = 16
    >> End If
    >>
    >> Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    >> Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    >> Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    >> End sub
    >>
    >> --
    >> steveB
    >>
    >> Remove "AYN" from email to respond
    >> "antonov" <[email protected]> wrote in message
    >> news:[email protected]...
    >>> Hello Steve...
    >>> I've tried your option but I still get the same error... the line is
    >>> highlighted and nothing happens
    >>> "STEVE BELL" <[email protected]> wrote in message
    >>> news:bkzEe.2457$uy3.1136@trnddc05...
    >>>> Try something like this
    >>>>
    >>>> Dim lrw as long
    >>>>
    >>>> lrw = Sheets("Sheet1").Cells(Rows.COUNT, "B").End(xlUp).Offset(1,0).Row
    >>>>
    >>>> If lrw < 16 then
    >>>> lrw = 16
    >>>> End If
    >>>>
    >>>> Sheets("Sheet1").Cells(lrw,2)=txtCode1.Value
    >>>> Sheets("Sheet1").Cells(lrw,3)=txtCode2.Value
    >>>> Sheets("Sheet1").Cells(lrw,4)=txtCode3.Value
    >>>>
    >>>> --
    >>>> steveB
    >>>>
    >>>> Remove "AYN" from email to respond
    >>>> "antonov" <[email protected]> wrote in message
    >>>> news:[email protected]...
    >>>>> ehmmm... a last question and hopefully I will be done with my sheet...
    >>>>> My sheet contains 2 tables of 4 columns / 17 rows each
    >>>>> The data for these tables SHOULD come from an userform (which I've
    >>>>> already made). When the "ready" button in the userform is pushed the
    >>>>> data should go in the first empty row (this is what I use for this
    >>>>> purpose):
    >>>>>
    >>>>> Private Sub cmdNext_Click()
    >>>>> ActiveWorkbook.Sheets("Sheet1").Activate
    >>>>> Range("B16").Select
    >>>>> Do
    >>>>> If IsEmpty(ActiveCell) = False Then
    >>>>> ActiveCell.Offset(1, 0).Select
    >>>>> End If
    >>>>> Loop Until IsEmpty(ActiveCell) = True
    >>>>>
    >>>>> Next step is where everything goes wrong:
    >>>>>
    >>>>> now the data has to be input in the right place and this is what I do:
    >>>>>
    >>>>> ActiveCell.Value = txtCode1.Value
    >>>>> ActiveCell.Offset(0, 1) = txtCode2.Value
    >>>>> ActiveCell.Offset(0, 2) = txtDate.Value
    >>>>> End sub
    >>>>>
    >>>>> Apparently this code is not working. All I get is the first line
    >>>>> highlighted and that's it.
    >>>>>
    >>>>> Furthermore: when the first table is full (4 colums / 17 rows) I need
    >>>>> the data to go to the next table which start at the same hight as the
    >>>>> first (say row 16) but 7 columns to the right....
    >>>>>
    >>>>> Sorry for the lenght of this but english is not my language and I
    >>>>> don't know how to keep it short...
    >>>>>
    >>>>> Thanks for any help....
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >




+ 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