+ Reply to Thread
Results 1 to 4 of 4

Locking values

  1. #1
    Registered User
    Join Date
    08-12-2009
    Location
    Perth, WA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Locking values

    Hi,
    How can go about the following?

    I have a worksheet with a macro that when clicked will update a data w/sheet with that months data.
    I then have an output w/sheet that displays the data in monthly columns.
    The problem is every time I run the macro to get the latest months data
    it changes the previous months data in the output w/sheet as well eg When I run the maco in August it also updates the column for July. I know I can lock the cells but can I lock the values so they dont change for July?

    Or can anyone suggest a more robust way of doing this?
    I've thought about doing some tedIous macros that will copy/paste/tanspose the values but like I said tedious.

    Example s/sheet provided for the interested...
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Locking values

    Please provide the code you are using presently.

    The best approach IMO would be to store the Month on the Monthly Data sheet this gives you added flexibility in that you can

    a) override existing data should there have been an error historically

    b) establish appropriate column to write to on Output sheet by means of simple Match

    As is your only option is to determine last column used and offset by one column but this means you can never amend/reload historic data.


    EDIT: just re-read your file and noted the reverse logic but points above remain in essence ... please post your existing code.
    Last edited by DonkeyOte; 09-17-2009 at 04:18 AM.

  3. #3
    Registered User
    Join Date
    08-12-2009
    Location
    Perth, WA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Locking values

    I've modified the example spreadsheet which i hope is more clearer.


    Sub Get_New_Data()
    '
    ' Get New Data button
    '
    '
    Range("A1").Select
    Windows("Calculation WORKBOOK.xls").Activate
    Columns("G:M").Select
    Selection.Copy
    Windows("Monthly Data.XLS").Activate
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A1").Select
    Application.CutCopyMode = False

    Range("A1:G100").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
    xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End Sub
    Attached Files Attached Files
    Last edited by hermithead; 09-17-2009 at 04:59 AM.

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Locking values

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1