+ Reply to Thread
Results 1 to 8 of 8

Number Format when writing data from VB to excel on a Userform

  1. #1
    Registered User
    Join Date
    04-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Number Format when writing data from VB to excel on a Userform

    I have a userform I have created using Visual Basics which has a simple combobox that selects a number from 0 to 10, when the okay button is clicked it send the number selected from the combobox to cell AE11 on my spreadsheet. when the data is sent across to the worksheet it is stored as text rather than a number and as the cell AE11 has formulas linked to it these formulas are not working due to the number being stored as text. Is there anyway of formatting the data so that when it is pulled across to the worksheet it is stored as a number rather than text?

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Number Format when writing data from VB to excel on a Userform

    Before taking the combo box value to AE11 cell add the below code and check

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    04-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Number Format when writing data from VB to excel on a Userform

    Hi Sixthsense, thanks for the quick response. I tried thw above, however, it didn't work, it's probably me putting the code in the wrong place, I am quite new to VBA.

    I have put the code in as below:
    Please Login or Register  to view this content.
    Not sure if this is correct?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Number Format when writing data from VB to excel on a Userform

    You Missed This...

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Nathan

    Use one of the conversion functions - CLng, CDbl, Val etc.

    Probably CLng in this case.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    04-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Number Format when writing data from VB to excel on a Userform

    I tried adding that but it still has the same error, when its writing the data over to the excel spreadsheet its still storing it in Cell AE11 as text which gives the error "Number stored as text"

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Number Format when writing data from VB to excel on a Userform

    Then the issue will be fixed if you follow Norie suggesion

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-12-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Number Format when writing data from VB to excel on a Userform

    Just seen Norie's post and it works, I have been trying to sort that out for nearly a week now thanks you both!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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