Code works in Project Developer but not when running in excel

jdwoods

New Member
Joined
Jan 6, 2010
Messages
17
I have a user form that user enters data in the white boxes, this data gets transferred to a worksheet then used to calculate answers for the grey boxes. When I run the program in developer it works just fine but when running it in excel it works the first time the file is opened but after you use the clear or close button and reuse the userform it does use the new data entered.
The file contains 3 worksheets
1. Is an instructions page that when you click on the instruction it opens the userform,
2nd is a weblink
3rd is the calculation data table.
What I am missing that makes it work in developer but not in excel.

1686341000398.png
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
The issue is located either in the vba code itself ... or there is a corruption of some kind in your workbook or EXCEL.

The best avenue would be to post a copy of your existing workbook that includes all vba code. This website does not provide a means to upload your workbook ... you'll need to post to a cloud website like DROPBOX.COM or something similar and post the download link here.
 
Upvote 0
I am not a fan how you are approaching writing the data to the worksheet. The 'standard approach' is to write all entries at the same time. I suspect your existing approach is
contributing to the errors seen.

Here is a different approach and a link to download the sample project. There are comments within the code to assist ...

VBA Code:
Option Explicit
Private Sub btnCancel_Click()
    Unload Me
End Sub

Private Sub btnOK_Click()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim newRow As Long
    
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    'The next two lines can be expanded as many times as needed for all the entry fields in your project
    'Col A = 1; Col B = 2; Col C = 3; Col D = 4; Col E = 5; Col F = 6; Col g = 7, etc. etc.
    
    ws.Cells(newRow, 1).Value = Me.txtFirstName.Text
    ws.Cells(newRow, 2).Value = Me.txtSurname.Text
    
    'continue the remainder adhering to the pattern seen above.
    
    
End Sub
Sub CommandButton1_Click()
    Selection.EntireRow.Delete
End Sub

Download example : https://share.internxt.com/d/sh/file/40ad1ccff19b9c35d37e/5e51d823db8586dc9eeea141bb0f33f898a011f25e1c85dd26c25fbff82ac16b
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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