Userform Submit button repeating data rather than adding new data

greegan

Well-known Member
Joined
Nov 18, 2009
Messages
643
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I have a call list for the agents in our call center and I need to know the date and time they make an outbound call from this list.

Due to the different ways agents enter the date and time in one cell, I have made it very simple for them now.

Select the cell and click the submit button in the userform I have provided. All it has is a SUBMIT button.

When its clicked, it will enter data to the Data worksheet. The current time and date and the agent's name are all collected from the Engine worksheet.

We are using 365 in a Windows 10 environment with some 32 and 64 bit machines.

The problem with my code I will provide below is the same time will be added to the data sheet for several records.

I thought it was working correctly until I found an agent's Data sheet with 150+ calls with the same time indicated.

Can someone please tell me where I'm going wrong?

VBA Code:
Private Sub UserForm_Activate()

    
'*************************************************
    Dim Frmhdl As LongPtr
    Dim lStyle As LongPtr

    Frmhdl = FindWindow(vbNullString, Me.Caption)

    lStyle = GetWindowLong(Frmhdl, GWL_STYLE)
    lStyle = lStyle Or WS_SYSMENU
    lStyle = lStyle Or WS_MINIMIZEBOX
    lStyle = lStyle Or WS_MAXIMIZEBOX

    SetWindowLong Frmhdl, GWL_STYLE, (lStyle)
    DrawMenuBar Frmhdl
'*************************************************

    With ufSample
        .Top = Application.Top + 100 '< change 125 to what u want
        .Left = Application.Left + 1000 '< change 25 to what u want
        .show vbModeless
    End With

Call SystemButtonSettings(Me, False)

On Error GoTo 0
Application.UserName = Worksheets("Engine").Range("B6").Value

lbInputDate.Caption = Worksheets("Engine").Range("B1").Value
lbInputTime.Caption = Worksheets("Engine").Range("B2").Value
'Call MyCell
lbUser.Caption = Worksheets("Engine").Range("B6").Value

0


End Sub

Thank you

-- g
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Should the time stamp should be amended in the userform every time the userform is activated ?

VBA Code:
'AFTER this line
Application.UserName = Worksheets("Engine").Range("B6").Value

'INSERT this line to recalculate values in B1 and B2
Application.Calculate
 
Upvote 0
Solution

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top