I am quite new to this forum so I apologise if I do something incorrectly.
I need to mirror individual cells from one worksheet to a multiple of other worksheets within the same work book. I was wondering if anyone had written a code that could do this that I could copy and paste in and edit to fit this document.
I have had a reasonable look through the forum for this answer but cant seem to find one that fits.
Thank-you,
Daniel1234
Last edited by Daniel1234; 03-05-2010 at 07:06 AM.
This is a fairly simple-minded version but works:
This code must go in the code for the worksheet that is the source of the data. I took you literally when you said "mirror"--this puts values in the same cell in the destination that is used in the source.Code:Public Sub Worksheet_Change(ByVal Target As Range) MirrorCells End Sub Public Sub MirrorCells() Dim DestinationWS As Variant DestinationWS = Array("sheet A", "sheet B") ' sheet names where you want the data to be copied Dim wsName As Variant For Each wsName In DestinationWS Worksheets(wsName).Range("A1") = Range("A1") ' repeat above line for each cell you want to copy Next wsName End Sub
Further, this code will copy all of the values of interest every time there is any change anywhere on the source sheet, even if the change is not one of the values to be copied. It is not difficult to make that more efficient but I didn't want to write a lot more code without knowing the specifics of your situation.
(Also, note that you posted to the Excel General forum, but are asking about VBA code. There is a forum specifically for that called Excel Programming.)
Making the world a better place one fret at a time
||||||
If someone helped you, please click on the star icon at the bottom of their post
If your problem is solved, please update the first post:
EDIT, Go Advanced button, set Prefix to SOLVED
[code]
' Enclose code in tags like this
[/code]
Don't attach a screenshot--just attach your Excel file! It's easier and will let us experiment with your data, formulas, and code.
When i pop it into the view code section i get this error
Run Time error '9'
Subscript out of Range
if i click on debug this line is highlighted in yellow
Worksheets(wsName).Range("A1") = Range("A1")
(Sorry for posting in the wrong section will make sure it doesnt happen again)
Thanks,
Daniel1234
Hi sorry have worked out where i went wrong i needed to put a space inbetween sheet and 1 works like a charm thankyou so much
Daniel1234
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks