ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Programming with Sorting (https://www.excelbanter.com/excel-programming/421341-macro-programming-sorting.html)

Neon520

Macro Programming with Sorting
 
Hi Everyone,

I'm not sure what is the different Macro and VBA, but I know that once Macro
is recorded, you can do some modification/tweak to it, right?

I recorded a Macro that will Unprotect a sheet and then sorting a section of
the sheet, and then Protect the sheet back with the original password.

First of all, I created this Macro, because Excel won't allow user to Sort
anything after the sheet is locked. I guess it's my way to get around it.
The purpose is to sort the sheet, obviously, without giving the password to
the user, but when I try it out, the sheet still ask for the password. Is
there a way to Hard Code the password in the Macro, so it won't ask for the
password when I run it?

Thank you for any suggestion.
Neon

JLGWhiz

Macro Programming with Sorting
 
ActiveWorkbook.Unprotect Password:="XXXXXXXX" <<<your password
'Do Events
ActiveWorkbook.Protect Password:="XXXXXXXX" <<<your password

"Neon520" wrote:

Hi Everyone,

I'm not sure what is the different Macro and VBA, but I know that once Macro
is recorded, you can do some modification/tweak to it, right?

I recorded a Macro that will Unprotect a sheet and then sorting a section of
the sheet, and then Protect the sheet back with the original password.

First of all, I created this Macro, because Excel won't allow user to Sort
anything after the sheet is locked. I guess it's my way to get around it.
The purpose is to sort the sheet, obviously, without giving the password to
the user, but when I try it out, the sheet still ask for the password. Is
there a way to Hard Code the password in the Macro, so it won't ask for the
password when I run it?

Thank you for any suggestion.
Neon


Neon520

Macro Programming with Sorting
 
Thank you so much, JLGWhiz. This works out really great.

"JLGWhiz" wrote:

ActiveWorkbook.Unprotect Password:="XXXXXXXX" <<<your password
'Do Events
ActiveWorkbook.Protect Password:="XXXXXXXX" <<<your password

"Neon520" wrote:

Hi Everyone,

I'm not sure what is the different Macro and VBA, but I know that once Macro
is recorded, you can do some modification/tweak to it, right?

I recorded a Macro that will Unprotect a sheet and then sorting a section of
the sheet, and then Protect the sheet back with the original password.

First of all, I created this Macro, because Excel won't allow user to Sort
anything after the sheet is locked. I guess it's my way to get around it.
The purpose is to sort the sheet, obviously, without giving the password to
the user, but when I try it out, the sheet still ask for the password. Is
there a way to Hard Code the password in the Macro, so it won't ask for the
password when I run it?

Thank you for any suggestion.
Neon



All times are GMT +1. The time now is 11:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com