+ Reply to Thread
Results 1 to 5 of 5

UserForm for data entry

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-12-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    134

    UserForm for data entry


    i have problem in User-form i program. i am not the pro.but i learning from this forum a lot so thanks every one especial moderators.
    as u can see in atteched file User-form "frmEntry" work fine to update the data in Trader worksheet. but i need help to program.for the "frmExit" which i program. u can look in to the database "Trader Worksheet" .it enter the data in next available row.instead of up dating the corresponding existing stock ticker.to sell the stock.also when i enter the second sell of stock it change the row which is already their.not in new row.

    so pl some one can help me to program this will be greatly appreciated
    Attached Files Attached Files
    Last edited by jay11; 02-15-2010 at 04:04 PM.

  2. #2
    Registered User
    Join Date
    12-27-2009
    Location
    Paris, France
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: pl pl help me on UserForm for data entry

    Hello,

    Try the following code

    Private Sub Enterdata_Click()
    Dim ws As Worksheet
    Dim R As Range
    Dim var
    Dim i&
    'check for a Ticker
    If Trim(Me.CombTicker.Value) = "" Then
      Me.CombTicker.SetFocus
      MsgBox "Please enter a Ticker"
      Exit Sub
    End If
    'correspondence with "Ticker" and "#of Stock"
    Set ws = Worksheets("TRADERSSPREADSHEET")
    Set R = ws.Range(ws.Cells(1, 3), ws.Cells(ws.[a65536].End(xlUp).Row, 5))   '"C1:Ex"
    var = R
    For i& = 4 To UBound(var, 1)
      If var(i&, 1) = Trim(Me.CombTicker.Value) And _
          var(i&, 3) = Trim(Me.CombNoofStock.Value) Then
        'copy the data to the database
        With ws
          .Cells(i&, 13).Value = Me.txtExitDate.Value
          .Cells(i&, 14).Value = Me.txtHighofDay.Value
          .Cells(i&, 15).Value = Me.txtLowofDay.Value
          .Cells(i&, 16).Value = Me.txtExitPrice.Value
          .Cells(i&, 17).Value = Me.txtcommission.Value
        End With
        Exit For
      End If
    Next i&
    'clear the data
    Me.CombTicker.Value = ""
    Me.CombNoofStock.Value = ""
    Me.txtExitDate.Value = Format(Date, "Medium Date")
    Me.txtExitPrice.Value = ""
    Me.txtcommission = 7
    Me.txtHighofDay.Value = ""
    Me.txtLowofDay.Value = ""
    Me.CombTicker.SetFocus
    End Sub
    Best regards.

    PMO
    Patrick Morange
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    02-12-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    134

    Re: pl pl help me on UserForm for data entry

    hi
    PMO
    Patrick Morange

    thanks for looking in the prob. i DL the file u attached but when i enter the exit data its not populated the corresponding row also it don't give me any error msg. but i can see that u populated the same but it not work whith me is that posible since i am using Excel 2003
    VB 6.3 so pl help sorry to be pain.
    thanks

  4. #4
    Registered User
    Join Date
    12-27-2009
    Location
    Paris, France
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: UserForm for data entry

    Hello,

    Change
      If var(i&, 1) = Trim(Me.CombTicker.Value) And _
          var(i&, 3) = Trim(Me.CombNoofStock.Value) Then

    by
      If Trim(CStr(var(i&, 1))) = Trim(Me.CombTicker.Value) And _
          Trim(CStr(var(i&, 3))) = Trim(Me.CombNoofStock.Value) Then

    Best regards.

    PMO
    Patrick Morange

  5. #5
    Forum Contributor
    Join Date
    02-12-2010
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    134

    Re: UserForm for data entry

    Quote Originally Posted by PMO View Post
    Hello,

    Change
      If var(i&, 1) = Trim(Me.CombTicker.Value) And _
          var(i&, 3) = Trim(Me.CombNoofStock.Value) Then

    by
      If Trim(CStr(var(i&, 1))) = Trim(Me.CombTicker.Value) And _
          Trim(CStr(var(i&, 3))) = Trim(Me.CombNoofStock.Value) Then

    Best regards.

    PMO
    Patrick Morange
    thanks a lot it work like charms
    thanks again

+ 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