Change my sheets

juneau730

Board Regular
Joined
Jun 7, 2018
Messages
115
Office Version
  1. 365
Platform
  1. Windows
Trying a little humor with the subject. :)

I recorded the following macro in excel, then shortened/simplified it. If I am in Developer Mode and run it from there, it works great, but.. I am trying to assign the code to a button. When I do and click the button, it appears to be running on the sheet where the button is, not the sheet where my data is.

Searching, I was not able to find how to correct this.

Code:
Sub Configure_Dates()    Range("E2:E7500").Select
    Selection.Replace What:=",", Replacement:=", ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("F2:F7500").Select
    Selection.Replace What:="@", Replacement:=" ", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("E2:E7500").Select
    Selection.NumberFormat = "m/d/yyyy"
    Range("G2:G7500").Select
    Selection.NumberFormat = "m/d/yyyy"
    Range("H2:H7500").Select
    Selection.NumberFormat = "m/d/yyyy"
End Sub
 
It's fixed, within the protection box, it allowed me to set the specific conditions. By checking the box to allow formatting of cells, row and columns of UNLOCKED cells. By allowing this, it allows the macro to run properly, formatting the dates, but still protects (locks out) the few columns I need protected.

Thanks a ton for the help!
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,225,754
Messages
6,186,826
Members
453,377
Latest member
JoyousOne

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