Solved

VBA Code correction to combine three tasks

Posted on 2011-09-06
6
251 Views
Last Modified: 2012-05-12
Dear Experts,
recently I asked three questions which were all solved with vba code and each solution works fine. Now I need to combine all three solution into one but my coding experience is not good enough.
See here:
http://www.experts-exchange.com/Microsoft/Applications/Q_27286592.html
http://www.experts-exchange.com/Microsoft/Applications/Q_27288516.html
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27159284.html

The code below is almost working :-)
1. The tracking does not fix the previous value only the new one in the new line
2. I want to secure the history sheet with a password to prevent any changes from users. At the same time code must work and be able to write values to that sheet..

thanks
Nils




Private Sub Worksheet_Change(ByVal Target As Range)
Dim vOld
Dim rng As Range
Set rng = Range("A5:AA100")

    If Not Intersect(Target, rng) Is Nothing Then
    Debug.Print (Target.Column)
        Target.Offset(0, 29 - Target.Column).Value = Now()
        Target.Offset(0, 30 - Target.Column).Value = Environ("UserName")
    vOld = Target
    End If

With Sheets("Tracking").Range("A" & Rows.Count).End(xlUp)(2)
    .Value = Now
    .Offset(, 1).Value = Environ("username")
    .Offset(, 2).Value = Target.Address
    .Offset(, 3).Value = vOld
    .Offset(, 4).Value = Target
End With

End Sub


Private Sub Workbook_Open()
    Sheets("Tracking").Protect Password:="123456", DrawingObjects:=True, _
        contents:=True, Scenarios:=True, _
        userinterfaceonly:=True
    Sheets("COA-Matrix")EnableAutoFilter = True
End Sub


0
Comment
Question by:Petersburg1
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
gowflow earned 250 total points
ID: 36488132
replace this
Sheets("COA-Matrix")EnableAutoFilter = True
by this
Sheets("COA-Matrix").EnableAutoFilter = True

Your missing the point "." before EnableAutoFilter

What else is not working ?
gowflow
0
 

Author Comment

by:Petersburg1
ID: 36488174
I want to use  the the same code for 3 excel files which are located in three different folders, however when I adapt the ranges in the excel files the code for all excel files is changes?
The code is currently saved in "sheet1". Looks like I do not know the architecture of where to save..
thanks for advise.
Where to save so I can adapt ranges and save together with each excel file?
thanks
0
 
LVL 29

Expert Comment

by:gowflow
ID: 36488241
You can save them in a module but then it depends how they are called. Can't you post them I will fix it for you ? easier for both of us
gowflow
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Petersburg1
ID: 36489230
looks like I have fixed it.
thanks for help anyway
0
 

Author Closing Comment

by:Petersburg1
ID: 36489237
thanks
0
 
LVL 29

Expert Comment

by:gowflow
ID: 36489290
tks for the grade
gowflow
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question