Clear sheet contents before copying from another sheet using a macro

azmatb

New Member
Joined
Oct 20, 2022
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Can i add code in the CommandButton to clear contents of Sheet1, before i copy data into Sheet1 from Sheet2 using a macro.
Or do i need to create a new Button to clear contents. I would like to do everything using one command button, clear then load data.
Just looking for some samples. Below is what i did using a new button and it works. But i would like this to be incorporated in one button, where i can clear then load data.
Sub sbClearCellsOnlyData()
Worksheets("School Employee Info").Range("A11:AF11").ClearContents
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
So why not simply put this line in the start of the load macro ??
VBA Code:
Worksheets("School Employee Info").Range("A11:AF11").ClearContents
 
Upvote 0

Forum statistics

Threads
1,215,044
Messages
6,122,827
Members
449,096
Latest member
Erald

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