Clear Contents From 2 Sheets

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
192
Office Version
  1. 2016
Platform
  1. Windows
The code below is on the "MAIN" page and I'd like add code to it so that it also clears cell contents on different sheet in the workbook.
The other sheet is named "SIGN UP' and the range of cells that need the contents cleared are C5:D44

I'd appreciate any assistance...

VinceF
Excel 2016


Sub RESETMAIN()
'
' RESETMAIN Macro
'

'
Range("D7:D8").Select
Selection.ClearContents
Range("D12:E51").Select
Selection.ClearContents
Range("L12:T51").Select
Selection.ClearContents
Range("AD51").Select
Selection.ClearContents
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
ActiveWindow.ScrollRow = 16
ActiveWindow.ScrollRow = 13
ActiveWindow.ScrollRow = 12
ActiveWindow.ScrollRow = 11
ActiveWindow.ScrollRow = 7
ActiveWindow.ScrollRow = 6
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 1
Range("V12:AD51").Select
Selection.ClearContents


End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this:

VBA Code:
Sub RESETMAIN()
' RESETMAIN Macro
'
  With Sheets("MAIN")
    .Range("D7:D8").ClearContents
    .Range("D12:E51").ClearContents
    .Range("L12:T51").ClearContents
    .Range("AD51").ClearContents
    .Range("V12:AD51").ClearContents
  End With

  With Sheets("SIGN UP")
    .Range("C5:D44").ClearContents
  End With

End Sub
 
Upvote 0
Solution
Dante,
Thank you for the reply...
I replaced the code as suggested but it didn't clear the cell contents on the "SIGN UP" sheet...
I'm not sure if it makes a difference but the cells that I'm trying to clear are from a drop down list.

VinceF
 
Upvote 0
Did you modify anything in the macro?

Do you have any other macros running?

It doesn't matter if the cell has a validation list, this clears the cell:

VBA Code:
 With Sheets("SIGN UP")
    .Range("C5:D44").ClearContents
  End With
 
Upvote 0
Did you modify anything in the macro?
Yes, I copied and pasted as below

Do you have any other macros running?
There are other Macro's in the workbook but nothing running

Below is the complete Macro as it is now...it still doesn't clear the cell contents on "Sign Up" sheet.

VBA Code:
Sub RESETMAIN()
' RESETMAIN Macro
'
  With Sheets("MAIN")
    .Range("D7:D8").ClearContents
    .Range("D12:E51").ClearContents
    .Range("L12:T51").ClearContents
    .Range("AD51").ClearContents
    .Range("V12:AD51").ClearContents
  End With

  With Sheets("SIGN UP")
    .Range("C5:D44").ClearContents
  End With
End Sub
 
Last edited by a moderator:
Upvote 0
.Range("C5:D44").ClearContents
Are you sure you want to clean that range of cells?
Do you have any other books open?


If you run the macro, it will effectively clear that range of cells in the "SIGN UP" sheet.


When you run the macro do you get a message?


You can put here an image of the "SIGN UP" sheet before running the macro, run the macro and put here the image of the "SIGN UP" sheet after running the macro.

:unsure:
 
Upvote 0
Dante,
I have some issues with the sheet that may be interfering with this...I'm going to try and clean up the workbook and if I may I'll get back to this with you.
VinceF
 
Upvote 0
Try the macro in a new workbook, create 2 sheets with the names "MAIN" and "SIGN UP".

Put some test data on the sheets and try the macro again in the new workbook, you will see that the cells are cleared.
 
Upvote 0
Dante,
Thank you very much, your fix is working excellently. I had another Macro working against me and once I cleaned it up yours worker great.
Again, thank you.
VinceF
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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