+ Reply to Thread
Results 1 to 5 of 5

Hide Formula inside macro

  1. #1
    Forum Contributor
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    2007, 2010, 2013, 2016.
    Posts
    169

    Hide Formula inside macro

    Hi. i want to hide and lock formula inside a macro worksheet. but after changing the format, the worksheet is lock and cannot use it unless unlocked.
    this is the macro
    Sub copydata()
    Dim lc As Integer
    lc = Sheets("Sheet1 (2)").Cells(6, Columns.Count).End(xlToLeft).Column + 1
    Sheets("Sheet1").Range("D4:D21").Copy Sheets("Sheet1 (2)").Cells(4, lc)
    Sheets("Sheet1").Range("D6:D21").ClearContents
    Sheets("Sheet1").Range("D4").ClearContents
    End Sub

    i have added 2 columns inside sheet1 that uses max and min functions, its this formula i want to hide and lock to prevent from correction or accidentally deleted by user.
    which line i have to modify? and how?
    totally clueless with macro. i get help by sktneer before
    thanks.
    by the way, can we lock the sheet name so that it can't be change by the user?
    thanks again.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Hide Formula inside macro

    Instead of using VBA for this, have you considered using sheet protection? You can set it up so that the formula is not even visible. Or, you could just hide the columns
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Contributor
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    2007, 2010, 2013, 2016.
    Posts
    169

    Re: Hide Formula inside macro

    Hi FDibbins,
    the added cell was meant to be seen just not to be manipulated. i have tried the conventional way in format/protection. protection is successful but i cannot input.
    "sheet1" by the way is getting values from "sheet1 (2)" (max/min). any connection? also in "sheet1 (2)" are there ways to protect values from changes by user (expanding columns)?
    if protection is off. everything works well.
    Last edited by getafixkwik; 05-17-2016 at 02:25 AM.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Hide Formula inside macro

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  5. #5
    Forum Contributor
    Join Date
    04-14-2014
    Location
    Philippines
    MS-Off Ver
    2007, 2010, 2013, 2016.
    Posts
    169

    Re: Hide Formula inside macro

    please see attached file. thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Would like to hide specific text inside macro vba code
    By keisen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2015, 07:08 PM
  2. [SOLVED] Formula/Macro to list down the dates that are inside a week number of a month
    By michaljireht in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-22-2014, 08:16 AM
  3. [SOLVED] AND formula does not work inside the macro module
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2013, 08:49 PM
  4. [SOLVED] Formula not working when put inside VBA macro
    By Chrispelletier in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2013, 10:00 AM
  5. And formula inside an if formula in a macro
    By Jessica.Bush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-22-2010, 01:20 PM
  6. Replies: 1
    Last Post: 05-31-2005, 10:18 AM
  7. Macro inside a formula
    By loopy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-05-2005, 11:26 AM

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