Limiting a macro to run on a SPECIFIC sheet ina Workbook

Colobri

New Member
Joined
Feb 18, 2020
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
  2. Web
Hi! I have a workbook with 3 worksheets in it. the 3rd sheet, called PRACTICEVERSION is just that, a sheet to practice the steps of the course. FYI, sheet 1 is the actua "form" that users will keep their records on. Sheet 2 is all text and gives them the Directions as to what to put in each cell. Sheet 3 (PracticeVersion) is an exact copy of the "Master", ie Sheet 1. If youre going to practice, make mistakes, etc., do so on the PracticeVersion. I wrote a macro to clear/delete any/all "student-input" data while retaining the formulas. But, unfortunately, if they happen to execute the macro on the REAL, MASTER sheet (Sheet 1) it deletes all of the data on THAT sheet, too! NOT a god thing! So, my question is, on the Macro below, how do I SPECIFY that executing the macro ONLY works if you are on the PRACTICEVERSION sheet and NOT if you are on the Master, REAL sheet?

Sub ClearingWF_PracticeVersion()
'
' ClearingWF_PracticeVersion Macro
'


Range("B2:B3").Select
Selection.ClearContents
Range("D15:D16").Select
Selection.ClearContents
Range("E15:E16").Select
Selection.ClearContents
Range("E18").Select
Selection.ClearContents
Range("L15:L16").Select
Selection.ClearContents
Range("L19:L20").Select
Selection.ClearContents
Range("M15:M16").Select
Selection.ClearContents
ActiveWorkbook.Save
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("B2").Select
ActiveWorkbook.Save
End Sub

Thank you!
 
When I hover on the toolbar icon it shows PERSONAL.xlsb!RefreshPracticeVersion.

I did delete my code and replace it with yours. I must have messed up as I got some error messages. I'll try it again. If I get the same messages, I'll take a screen shot.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
MrExcel: I got it! THANK YOU! I received an error message, went in and added a space between Practice and Version, and it worked. Double checked again, it worked. THANK YOU!!!!!
 
Upvote 0
Glad you got it sorted & thanks for the feedback.

PS, my name is Fluff not MrExcel. ;)
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

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