User Form won't clear Data in worksheet

jdwoods

New Member
Joined
Jan 6, 2010
Messages
17
I have a user form that inputs data to workbook, when I run the user form in VBA developer everything works properly. The problem is I open the excel file and run the program the data does not clear in the workbook therefore making my calculations wrong. What is causing the workbook not to clear in when running the program outside the developer page? I can provide more details if needed.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What is the code that should clear the worksheet?
 
Upvote 0
Sub sbClearEntireSheetOnlyData()
Sheets("Canola Data Table").Range("A10:D10").ClearContents
End Sub

When you click on the clear button on the user form nothing happens. It does clear the textboxes or the data table. I need both to clear so user can re use the form over and over. Data in the table also wont' clear when closed, the user form resets. Below is what I am using to close the user form.
Private Sub CmdClose_click()
Unload Me
End Sub
 
Upvote 0
How have you linked that code to the button?
 
Upvote 0
What happens if you change this to:
VBA Code:
Sub sbClearEntireSheetOnlyData()
    ThisWorkbook.Sheets("Canola Data Table").Range("A10:D10").ClearContents
End Sub
 
Upvote 0
Solution
What happens if you change this to:
VBA Code:
Sub sbClearEntireSheetOnlyData()
    ThisWorkbook.Sheets("Canola Data Table").Range("A10:D10").ClearContents
End Sub
I tried this but still nothing, do i have to add a module to the user form referencing this code to get the CMD Button to work.
 
Upvote 0
What's the code behind the commandbutton?
 
Upvote 0

Forum statistics

Threads
1,215,659
Messages
6,126,071
Members
449,286
Latest member
Lantern

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