+ Reply to Thread
Results 1 to 2 of 2

How to make the following VBA code work for multiple cells without rewriting same code

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    Reno, NV
    MS-Off Ver
    Excel 2013
    Posts
    33

    How to make the following VBA code work for multiple cells without rewriting same code

    Hello All,

    I have the the following code in the attached excel sheet.

    I would like to have it work the same for the following

    cell d21 when it contains "" show Width
    and e21 when it contains "" show Height

    Also, if i click out of the cell twice it goes to black instead of grey??

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$C$21" Then
    If Target.Value = "Length" Then
    Target.Font.ColorIndex = 15
    Target.Value = ""
    Exit Sub
    End If
    End If
    If [C21].Value = "" Then
    [C21].Value = "Length"
    [C21].Font.ColorIndex = 15
    Else
    [C21].Font.ColorIndex = xlAutomatic
    End If
    End Sub
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-21-2012
    Location
    Reno, NV
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: How to make the following VBA code work for multiple cells without rewriting same code

    Does Anyone have any ideas?

+ 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. how make vba code work over range of cells
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2013, 11:42 PM
  2. How to make this code work for cells with formulas in them
    By daniellerhea in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2013, 04:11 AM
  3. Replies: 0
    Last Post: 06-28-2012, 01:08 AM
  4. [SOLVED] How to make this code work even if the cells are locked and sheet is protected
    By nenadmail in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2012, 01:14 PM
  5. Rewriting macro recorded code for efficiency
    By jhizon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2011, 01:53 PM

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