Copy cell formatting thru formula

sharan

New Member
Joined
Jan 28, 2003
Messages
11
Hi!!

My requirement is as follows

i have 2 sheets in my workbook

1. sheet1 (user input)
2. sheet2 (write protected, only for viewing data)

Range "a8" in "sheet1" and "a8" in "sheet2" are related

when user changes the formatting of Range "a8" in "sheet1",

i want it to be reflected in "sheet2"

i tried it in the following way, but did not work

a. made a macro(copy_data) that will copy the contents with formatting

b. i had set the formula for range "a8" in sheet2 as "=copy_data(sheet1!a8)"


this method didnt work out
Please help
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
try something like =Sheet1!B13

an easy way to do this is select the cell you want the data to be copied to in the forula bar press = then go to the cell you wich the data to be copied from when the cell is selected press the Tick.

Hope this helps
 
Upvote 0
You can use this macro:

Sub CopyPaste()
Sheets("Sheet1").Select
Range("A8").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A8").Select
ActiveSheet.Paste
End Sub
 
Upvote 0
Hi Barry!!

this did work, but not as expected, i made the following function


Public Function copy_cont(a_range As Range) As String

a_range.Select
Selection.Copy
Set a_range = a_range.Next
a_range.Select
ActiveSheet.Paste

End Function


i used the following formula for a cell

=copy_cont(A1)

but nothing happened

i made a command button and assigned the code as



Private Sub CommandButton1_Click()

copy_cont Range("a1")

End Sub


when i click the command button it works,

but i wanted it to work in a formula

Expecting a suggestion
 
Upvote 0
You are running into 2 difficulties:

(1)
Formulas do not change formatting. A calculation event can capture changes in formulas but see below for a more efficient approach.

(2)
Formatting a cell will not trigger an event.

To achieve the effect of seeing cell A8 in Sheet2 look just like cell A8 in Sheet1, the following should suffice in most cases.

Right click on the Sheet2 tab, left click on View Code, and paste this into the large white area that is the Sheet2 module:

''''''''''''''''''''''''''''''''''''''''''''

Private Sub Worksheet_Activate()
ActiveSheet.Unprotect ("YourPassword")
Worksheets("Sheet1").Range("A8").Copy Range("A8")
ActiveSheet.Protect ("YourPassword")
End Sub

''''''''''''''''''''''''''''''''''''''''''''

Modify for password. Return to the worksheets by pressing Alt+Q.
 
Upvote 0
Thanks!! TOM

It was amazing, it worked out..

I thank all Mr. Excel.com members for giving a thougt to my problem.
 
Upvote 0

Forum statistics

Threads
1,223,721
Messages
6,174,096
Members
452,542
Latest member
Bricklin

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