Excel formatting help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patswin
    SBR MVP
    • 09-05-06
    • 1794

    #1
    Excel formatting help
    quick question, hopefully an easy one. i want to scrape data from a web site. I am doing it though excel web query function on excel 2007. When i get the data, the number formats change. For example, in one cell the data is 5-3, but when it goes into excel it automatically formats into a date 5/3/2011. how can i get it to keep it 5-3? I tried reformatting the cell but nothing seems to work. Can someone explain how to get it to work

    Thanks
  • thompsontw
    SBR High Roller
    • 03-07-10
    • 165

    #2
    Select all your data cells that you want to change the format on then Go into the Format Cells window and the Number tab then Custom Category then type m-d in the Type box.
    Comment
    • patswin
      SBR MVP
      • 09-05-06
      • 1794

      #3
      ok that worked but now when i update the spreadsheet it still changes it to date format. anyway to lock the cell into the m-d format?
      Last edited by patswin; 04-11-11, 03:31 PM.
      Comment
      • WendysRox
        SBR High Roller
        • 07-22-10
        • 184

        #4
        I'm sure there are better programmers out there than can tell you how to do that. But, the way I would do it with my limited knowledge is to record a macro of you changing the formats, then after you scrape the data all you have to do is run that macro.

        I do the same thing to get rid of periods that show up when I'm scraping (a website I use puts periods when the value is null).
        Comment
        • mrtomk
          SBR High Roller
          • 02-24-11
          • 105

          #5
          I'm reading this as 5-3 is a team's record or something and not in any way a date? I think its a matter of formatting the cells/sheet in question, prior to importing the data, to Text, following the steps outlined by the previous poster.

          If you import the 5-3 prior to formatting the cells, Excel with convert it to a date, or number based on the date, in this case 40666.
          Comment
          • Pushkin
            Restricted User
            • 08-26-10
            • 28

            #6
            In the Web Query, after you have selected the data that you are going to import into your spreadsheet (but before you click the import button), click on the options menu in the Web Query and than disable the date recognition. Now it'll import into your spreadsheet properly.
            Comment
            • Insoluble
              SBR Hustler
              • 05-29-10
              • 71

              #7
              This should do the trick for you:

              Comment
              • MonkeyF0cker
                SBR Posting Legend
                • 06-12-07
                • 12144

                #8
                Assuming that you're doing it programmatically and creating a range of cells for importing the data, it's simply the following command to format the cells in that range to text...

                Worksheets("SheetName").Range("Cell1:Cel l2").NumberFormat = "@"

                Otherwise, the previous post would alleviate that.
                Comment
                • Jenney001
                  SBR Rookie
                  • 03-04-11
                  • 8

                  #9
                  learn more from reply..
                  Comment
                  • patswin
                    SBR MVP
                    • 09-05-06
                    • 1794

                    #10
                    thanks guys for your help! got it to work ok now
                    Comment
                    • arwar
                      SBR High Roller
                      • 07-09-09
                      • 208

                      #11
                      i add a string like --> before the data (that gets unwillingly converted to date like 6-10 for height - i use '--> 6-10' -no quotes - though you can use quotes as well) anyway after loading then delete the '-->'
                      Comment
                      • ScreaminPain
                        SBR High Roller
                        • 09-17-08
                        • 246

                        #12
                        One solution is this:

                        right-click on your spreadsheet
                        click on Edit Query
                        in small print at the very top right is "options" ...click on it
                        when the new box opens find the phrase "disable date recognition" and check the box next to it.
                        close
                        close
                        close

                        Your problems will be solved..
                        Comment
                        SBR Contests
                        Collapse
                        Top-Rated US Sportsbooks
                        Collapse
                        Working...