Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Macro that unprotects worksheets, transfers data, then reprotects

I am not fluent in visual basic. For the most part I record operations and
then cut/paste them to my main macro.

Right now I am working with a workbook with 4 sheets.

Sheet1 - All locked except cells B5-B8 and B11-B17
- Protected

Sheet2 - All locked
- Protected

Sheet3 - All locked
- Protected

Sheet4 - All locked
- Protected

When I engage the macro the first operation is --

Sheets("Sheet1").Select
ActiveSheet.Unprotect
Sheets("Sheet2").Select
ActiveSheet.Unprotect
Sheets("Sheet3").Select
ActiveSheet.Unprotect
Sheets("Sheet4").Select
ActiveSheet.Unprotect

This works.

The next operation in the macro is to take values on sheet 1 and transfer
them to the other sheets. Here is an example of the data stored on sheet 1
in cell B5 --


Sheets("Sheet1").Select
Range("B5").Select
Selection.Copy
Sheets("Sheet2").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("B13").Select
ActiveSheet.Paste

After all the transfering of data from Sheet 1 to the other sheets is done I
added this code to reProtect each sheet so that noone could manipulate the
data. --

Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

The problem I have is since Sheet 1 cell B5-B8 and B11-B17 are not locked
when the macro transfers the data in these cells to cells in Sheet 2,3, and 4
those cells that were locked are not anymore.

How do I set my macro so that when it takes data from Sheet1 Cell B5-B8 and
B11-B17 that it does not unlock the cells the data is transfered to?

Thank you for your help.
Ryan Hess
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro that unprotects worksheets, transfers data, then reprotects

Hi ryanmhess

Try to use Value instead of copy
You don't have to select the sheets

Sheets("Sheet2").Range("D7").Value = Sheets("Sheet1").Range("B5").Value

--
Regards Ron de Bruin
http://www.rondebruin.nl


"ryanmhess" wrote in message ...
I am not fluent in visual basic. For the most part I record operations and
then cut/paste them to my main macro.

Right now I am working with a workbook with 4 sheets.

Sheet1 - All locked except cells B5-B8 and B11-B17
- Protected

Sheet2 - All locked
- Protected

Sheet3 - All locked
- Protected

Sheet4 - All locked
- Protected

When I engage the macro the first operation is --

Sheets("Sheet1").Select
ActiveSheet.Unprotect
Sheets("Sheet2").Select
ActiveSheet.Unprotect
Sheets("Sheet3").Select
ActiveSheet.Unprotect
Sheets("Sheet4").Select
ActiveSheet.Unprotect

This works.

The next operation in the macro is to take values on sheet 1 and transfer
them to the other sheets. Here is an example of the data stored on sheet 1
in cell B5 --


Sheets("Sheet1").Select
Range("B5").Select
Selection.Copy
Sheets("Sheet2").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("B13").Select
ActiveSheet.Paste

After all the transfering of data from Sheet 1 to the other sheets is done I
added this code to reProtect each sheet so that noone could manipulate the
data. --

Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

The problem I have is since Sheet 1 cell B5-B8 and B11-B17 are not locked
when the macro transfers the data in these cells to cells in Sheet 2,3, and 4
those cells that were locked are not anymore.

How do I set my macro so that when it takes data from Sheet1 Cell B5-B8 and
B11-B17 that it does not unlock the cells the data is transfered to?

Thank you for your help.
Ryan Hess



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Macro that unprotects worksheets, transfers data, then reprote

Thank you very much Ron, that worked out nicely and it helped my macro run a
little faster!

Thank you,
Ryan Hess

"Ron de Bruin" wrote:

Hi ryanmhess

Try to use Value instead of copy
You don't have to select the sheets

Sheets("Sheet2").Range("D7").Value = Sheets("Sheet1").Range("B5").Value

--
Regards Ron de Bruin
http://www.rondebruin.nl


"ryanmhess" wrote in message ...
I am not fluent in visual basic. For the most part I record operations and
then cut/paste them to my main macro.

Right now I am working with a workbook with 4 sheets.

Sheet1 - All locked except cells B5-B8 and B11-B17
- Protected

Sheet2 - All locked
- Protected

Sheet3 - All locked
- Protected

Sheet4 - All locked
- Protected

When I engage the macro the first operation is --

Sheets("Sheet1").Select
ActiveSheet.Unprotect
Sheets("Sheet2").Select
ActiveSheet.Unprotect
Sheets("Sheet3").Select
ActiveSheet.Unprotect
Sheets("Sheet4").Select
ActiveSheet.Unprotect

This works.

The next operation in the macro is to take values on sheet 1 and transfer
them to the other sheets. Here is an example of the data stored on sheet 1
in cell B5 --


Sheets("Sheet1").Select
Range("B5").Select
Selection.Copy
Sheets("Sheet2").Select
Range("D7").Select
ActiveSheet.Paste
Sheets("Sheet3").Select
Range("B13").Select
ActiveSheet.Paste

After all the transfering of data from Sheet 1 to the other sheets is done I
added this code to reProtect each sheet so that noone could manipulate the
data. --

Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("Sheet4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

The problem I have is since Sheet 1 cell B5-B8 and B11-B17 are not locked
when the macro transfers the data in these cells to cells in Sheet 2,3, and 4
those cells that were locked are not anymore.

How do I set my macro so that when it takes data from Sheet1 Cell B5-B8 and
B11-B17 that it does not unlock the cells the data is transfered to?

Thank you for your help.
Ryan Hess




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Transfers?? GA85 Excel Discussion (Misc queries) 1 September 24th 08 11:58 AM
Transfers [email protected] Excel Worksheet Functions 3 October 8th 05 03:16 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM
Automatic transfers Terri Excel Worksheet Functions 1 May 10th 05 09:05 PM
FTP Transfers with VBA E.Anderegg Excel Programming 3 September 25th 03 05:09 PM


All times are GMT +1. The time now is 06:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"