Clear form after add buton is pressed and data transferred onto other sheet

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hello, please can you help me with the code below that works great but i just wanted the data in the form to clear once the add button has been pressed and all data has be transferred to the other sheet, is there any way for it to 'Clear' once the button is pressed? please can you help me? thank you again for your time much apprecated, i am a beginner and loving this coding and learning. :)

Code:
Private Sub CommandButton2_Click()

Dim NxtRw As Long
Application.ScreenUpdating = False

NxtRw = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Row
With Sheets("Northants")
Sheets("Sheet2").Range("A" & NxtRw).Resize(, 8).Value = Application.Transpose(.Range("B22:B29").Value)
Sheets("Sheet2").Range("I" & NxtRw).Value = .Range("C29").Value
Sheets("Sheet2").Range("J" & NxtRw).Resize(, 2).Value = Application.Transpose(.Range("B30:B31").Value)
End With

Application.ScreenUpdating = True
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
u need to code each control to clear ie. Userform1.Listbox1.clear; Userform1.textbox1.value = vbnullstring; etc. . Alternatively, U can "Unload Me" then re-load the form. HTH. Dave
 
Upvote 0
hiya thank you for the response back, i am sorry but i dont understand what you mean, i am very new to VBA coding, if you can explain a little bit more please i would be most greatful.
 
Upvote 0
Which sheet do you want to clear & what are the ranges?
 
Upvote 0
Hi there the sheet i want clearing is 'Northants' cell 'C19', thank you for your patience and help,
 
Upvote 0
Try
Code:
Sheets("Northants").Range("C19").Clear
 
Upvote 0
thank you where do i place this in the current code? thank you again for your patience
 
Upvote 0
Anywhere after you have copied the data to the other sheet.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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