Linking an Excel Sheet to another in the same workbook using VBA -


i'm trying keep track of been done in workbook, have copy of sheet comments added date of change , user changed it(don't care change want know cells change dates , username), yes know can use copy , paste link, vba script have right doesn't recognize changes made in original sheet code below:

    private sub worksheet_change(byval target excel.range) 'if target.column <> 1 exit sub dim ccc range dim comment string application.screenupdating = false application.calculation = xlmanual  comment = ("cell last edited: ") & & (" ") & application.username target.clearcomments     each ccc in target     range(ccc.address).addcomment comment     next ccc  application.screenupdating = true application.calculation = xlautomatic end sub 

in works nice, clear want script copies original sheet 1 , if make change copy or modified copy sheet , add comment date , username

any suggestion great , in advance :d

not sure if keeping duplicate of sheet easiest way: if users insert new rows or columns (thousands) or cells within existing data, or charts, etc

i'd suggest keeping log of changes similar this

  • given workbook 2 sheets (sheet1 , sheet2)
  • sheet1 contains data
  • sheet2 contain log 4 columns: date, user name, cell, new value

then sheet1 contain vba code:


option explicit  private logline long  private sub worksheet_change(byval target range)      if target.countlarge < 1000    ' don't log deletion of cells on sheet1          dim editedcell string          ' clean cell address ("a1" instead of "$a$1")         editedcell = target.address(rowabsolute:=false, columnabsolute:=false)          sheet2     ' generate log lines on sheet2              logline = logline + 1   ' move next row on sheet2              ' column 1: date , time             .cells(logline, 1).value2 = format(now, "ddd mmm dd, yyyy hh:mm:ss")              ' column 2: user name             .cells(logline, 2).value2 = application.username              ' column 3: link edited cell, showing cell             .hyperlinks.add _                 anchor:=.cells(logline, 3), _                 address:=vbnullstring, _                 subaddress:="sheet1!" & editedcell, _                 texttodisplay:=editedcell              ' column 4: new value             .cells(logline, 4).value2 = target.value2         end     end if end sub 

on sheet2 you'll have 4 columns:

        date-time          user nane   cell    new value wed jun 03, 2015 01:07:43   user1       a1      test 1 wed jun 03, 2015 01:07:48   user2       b3      test 3 wed jun 03, 2015 01:07:52   user5       d2      test 7 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -