+ Reply to Thread
Results 1 to 8 of 8

Formatting numbers with vba

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Formatting numbers with vba

    I have written the following code to fill m sheet with data and then format the range of the data to remove the decimals.
    Please Login or Register  to view this content.
    The sub PasteDownN is simply a routine to copy and paste a row of formulae to a range and then change that range to values


    I get the error message "unable to set the NumberFormat property of the Range Class" at the line marked "xxxxxxxxx"
    I cant find why. I am sure that NumberFormat is a property of Range but perhaps I am wrong. Can somebody help please?
    John

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,097

    Re: Formatting numbers with vba

    Does the PasteDownN sub re-apply protection?

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Formatting numbers with vba

    Fluff13
    Yes it does. Is the protection the problem?

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Formatting numbers with vba

    Hard to tell without seeing the data, especially .Range("H10:S65"). Are these ranges formatted with something other than a number? The syntax is solid.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Formatting numbers with vba

    You will not be able to change the number format if sheet is protected.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Formatting numbers with vba

    Unless the cells are unlocked and you allowed formatting cells in the protection options.
    Remember what the dormouse said
    Feed your head

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Formatting numbers with vba

    Well, that was straight forward enough!
    Many thanks for your help it seems obvious now but I had tried many options for hours without success.
    John

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,097

    Re: Formatting numbers with vba

    Glad it's sorted & thanks for the feedback.

+ 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. Formatting numbers
    By attroll in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-20-2018, 02:31 PM
  2. [SOLVED] Conditional formatting - formatting the lowest 2 numbers in a list of 12 numbers
    By ktbb0312 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-09-2013, 09:59 AM
  3. Replies: 9
    Last Post: 03-26-2012, 02:16 PM
  4. Formatting numbers
    By owensjb2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2011, 02:02 AM
  5. Whole numbers:formatting numbers
    By trickyricky in forum Excel General
    Replies: 2
    Last Post: 12-28-2010, 03:37 PM
  6. Formatting Numbers
    By slovenc0417 in forum Excel General
    Replies: 6
    Last Post: 09-28-2009, 06:02 AM
  7. Formatting numbers.
    By prefect20 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2008, 03:18 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