+ Reply to Thread
Results 1 to 5 of 5

Making a macro applicable only to certain cells

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question Making a macro applicable only to certain cells

    I am working on a protected worksheet so the VBA macro I wrote unprotects the sheet, do it's job and then reprotects the sheet. This works fine but It allows my macro to be applied to any cell. How can I make sure the VB macro can only be applied to pre-determined cells.

    Here is my actual VB code

    Sub TimeStamper()
    Feuil1.Unprotect Password:="password"
    ActiveCell.Value = Now
    ActiveCell.NumberFormat = "H:MM:SS AM/PM"
    ActiveCell.Interior.ColorIndex = 36
    Feuil1.Protect Password:="password"
    ThisWorkbook.Save
    End Sub

    Thank you

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Making a macro applicable only to certain cells

    Please use code tags with your code as per forum's rule.

    What are the pre-determined cells?

  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Making a macro applicable only to certain cells

    A total of 98 groups of 4 cells.... that a lot of cells!!!
    for example the first few groups are C4:C7, F4:F7, I4:I7, L4:L7, O4:O7, R4:R7, U4:U7

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Making a macro applicable only to certain cells

    Use

    Please Login or Register  to view this content.
    Instead of active cell

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Making a macro applicable only to certain cells

    Thank you, works perfectly

+ 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. Making one Macro work for any range of cells instead of creating several
    By liberator14 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 06:02 PM
  2. [SOLVED] Making Simple Recorded Macro Generally Applicable
    By One-Eyed Enos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2012, 11:16 AM
  3. Steps to make a macro applicable to any cell that I choose
    By Digestive in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2011, 08:55 PM
  4. IF formula recognizing blank cells as #NA or #NULL applicable to VBA?
    By Allison!~!@ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2007, 11:12 AM
  5. [SOLVED] Splitting cells using formula; RIGHT/LEFT not applicable
    By Mitch in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-16-2006, 02:50 AM

Tags for this Thread

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