Excel VBA to Excel Sheet data saving Question.

mr_bhavesh

New Member
Joined
Nov 24, 2024
Messages
1
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
Platform
  1. Windows
  2. Mobile
  3. Web
The userform of the above code has 3 textbox and 1 commandbutton for submit (data save to sheet),

After clicking submit, data is saved more than once in Range A:C, while data is saved only once in Range D:F and Range G:I, or if any correction is made in the textbox, the saved data is updated.

Is there an error in the code? Or has something gone wrong? help me
 

Attachments

  • 1000162572.jpg
    1000162572.jpg
    252.7 KB · Views: 3

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How did you determine that the data is saved more than once in A:C?
If you want to save the textboxes content to the destination cell when their content changes then you need to use the Textbox_Change event, but this will trigger for any change not when the final value has been typed. Or you could use the TextBox_Exit event, that however will trigger only if you move the focus to a different control.
Also, keep in mind that a textbox returns a "text", so maybe it would be better if you use, for example If txt_line.Text = "11" Then '11 as a string
 
Upvote 0

Forum statistics

Threads
1,223,993
Messages
6,175,846
Members
452,675
Latest member
duongtruc1610

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