Results 1 to 3 of 3

Cannot use Custom Number Format. Need help with a VBA code

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    19

    Cannot use Custom Number Format. Need help with a VBA code

    I created a pivot table and using data from the sites tab (see attached file). In order to transfer the business hours access info over to the pivot table (sheet 1), I created a Legend column (columns B & C) 1=Full, 2=Ltd, 3=full. Under the values, I customized the number format to [=1]"Full";[=2]"Ltd";"None". Here’s the problem I have to add 4=NS; 5=Closed. Unfortunately custom number format only allows 3 changes. The only alternative I see is to use a vba code. Can anyone help me?

    I’m a novice to vba. I tried this for Sheet 1 but it got me nowhere.

    Sub Substitute()
    Dim rng As Range, Cell As Range
    Set rng = Sheets("Sheet1").Range("B1:B:629)
    For Each Cell In rng
    Cell = WorksheetFunction.replace(Cell, "1", "Full")
    Cell = WorksheetFunction.replace(Cell, "2", "Ltd")
    Cell = WorksheetFunction.replace(Cell, "3", "None")
    Cell = WorksheetFunction.replace(Cell, "4", "NS")
    Cell = WorksheetFunction.replace(Cell, "5", "Closed")
    Next
    End Sub
    I also need to do the same for column C.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need a VB Code for Pivot Table instead of using custom format code
    By Linus100 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-02-2014, 01:13 PM
  2. Custom number format code for hiding specific values on chart axes
    By rob_storrar in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 11-25-2012, 12:27 AM
  3. how do I add phone number format as a permanent custom format?
    By frustratedagain in forum Excel General
    Replies: 3
    Last Post: 02-03-2006, 11:52 PM
  4. [SOLVED] Format a cell with a custom number format
    By Armor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-29-2006, 07:30 PM
  5. Custom number format always defaults last number to 0.
    By scubadave in forum Excel General
    Replies: 2
    Last Post: 06-15-2005, 06:05 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