+ Reply to Thread
Results 1 to 15 of 15

VBA not working with imported numbers

  1. #1
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    VBA not working with imported numbers

    Hi,
    Yesterday Sintek very kindly provided me with vba to calc and display the differnce in a col of changing numbers ... which works exactly how I wanted,
    However, I find that when I apply the vba in situ on my spreadsheet (that is connected to the source of the numbers) it dosn't react to the incoming changing numbers. It works if I type numbers in, but does nothing with the displayed numbers.

    Any help appreciated
    Thanks
    Paul

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,447

    Re: VBA not working with imported numbers

    Hi Paul,

    The most likely answer is that the imported numbers are really TEXT!! You can convert all those text-numbers to real numbers by adding zero to them or multiplying them by one!

    See if that works.

    Here are some other ways to convert them:

    https://fasteratexcel.com/excel-conv...umbers-format/
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,201

    Re: VBA not working with imported numbers

    My guess is that your imported numbers are stored in Excel as text, not numbers. There are many ways to resolve this, here is one:

    1. Enter a 1 in a blank cell and copy it.
    2. Select the cells containing the numbers, right-click and select Paste Special, Paste Special.
    3. From the dialog box that opens, select Multiply, and click OK.
    4. The act of multiplying the values by 1 forces the contents of the cells to become their numerical values.


    If you find a method that works for you, you can run the macro recorder, and then incorporate that code into your other VBA.

    There could be other ways to revise the VBA, but since you didn't provide it I can't offer any further suggestions. If you attach your file we can give a solution for your specific file.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    Thank you both for your suggestions, I have tried various ways like adding 0 and multiply x 1 but to no effect,
    also the incoming numbers are formatted as currency, so i sm thinking thats ok from a formatting point of view?
    Thanks
    Paul

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: VBA not working with imported numbers

    Perhaps...the the code supplied is not for your actual setup...Not correct Event used...
    https://www.excelforum.com/excel-pro...f-figures.html
    How is the values in [C3] being updated...
    Last edited by Sintek; 09-23-2018 at 11:32 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    the sheet connects to a trading platform, they tell me it's an "event change"
    Thanks
    Paul

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: VBA not working with imported numbers

    As per Jeff...
    If you attach your file we can give a solution for your specific file.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,447

    Re: VBA not working with imported numbers

    Hi Sherman,

    If you have a currency symbol in those "text numbers" like ($4.50) then multiplying by 1 or adding zero won't work. You first need to remove the dollar sign (or currency symbol) before doing my techniques above.

    Use the Substitute() function in Excel to remove the dollar sign.

  9. #9
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    thanks .. I'll try and sort that tomorrow .. the only thing is that there won't be any numbers comming in as it needs to be connected to the trading software, so not sure how that would work.
    Thanks
    Paul

  10. #10
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    Quote Originally Posted by sintek View Post
    As per Jeff...
    The thing is you would need to be subscribed at cost to the trading software to be able to reproduce the situation.
    What I have found though is that there is nothing special about their spreadsheet, I have been able to connect a new blank sheet and the numbers load just the same, presumably they are fed via an API. If I overtype the incoming numbers they just revert back to the feed numbers .. does that give any clues as to the nature of them ?

    Just to update where i am .. I put the code below into the sheet (worked from Sintek example) and find the following ...

    ie if I type 24 into H9, then 24 will appear in AN9, then if I change H9 to 26, then AN9 will display 2 ..etc this works fine
    But If I connect the sheet to the trading software and lets say H9 shows 24, nothing will appear in AN9, and nothing will happen when H9 changes ..
    It seems that the numbers displayed on a "Connected" sheet arn't recognised ..

    Thanks
    Paul

    Please Login or Register  to view this content.

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,027

    Re: VBA not working with imported numbers

    If I connect the sheet to the trading software and lets say H9 shows 24, nothing will appear in AN9, and nothing will happen when H9 changes ..
    I still think a different event needs to be used...Not sure which one though...

    If the cell is populated by code and undo function could not work...
    Is the cell populated by a formula...Still need to find out how C3 gets its value from the API
    Last edited by Sintek; 09-25-2018 at 06:07 AM.

  12. #12
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    thanks,
    the cells that recieve the constantly updated numbers are empty, no code refers to it or formula .. I have tried with a newly created blank sheet ..
    cheers
    Paul

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: VBA not working with imported numbers

    How many cells do you need to monitor?
    Everyone who confuses correlation and causation ends up dead.

  14. #14
    Registered User
    Join Date
    08-26-2015
    Location
    Staffordshire UK
    MS-Off Ver
    2007
    Posts
    98

    Re: VBA not working with imported numbers

    up to 30 ..

  15. #15
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: VBA not working with imported numbers

    I'd suggest trying the Calculate event of that sheet, or add an ActiveX textbox, link it to the first of the output cells, and then use its Change event to process all of the cells.

+ 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. Need help working with data imported from Quickbooks
    By cuttingirl in forum Excel General
    Replies: 1
    Last Post: 08-13-2015, 02:25 PM
  2. [SOLVED] Change imported numbers in text format to numbers
    By navialivad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2014, 02:30 PM
  3. Imported Dates not working in formula
    By pjw23 in forum Excel General
    Replies: 3
    Last Post: 02-03-2011, 09:00 PM
  4. Formulas Not Working on Imported Data
    By Macro-wave in forum Excel General
    Replies: 4
    Last Post: 01-21-2011, 02:06 PM
  5. Imported VBA code not working....
    By HuskerBronco in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-02-2008, 05:57 PM
  6. Replies: 2
    Last Post: 04-21-2006, 08:45 AM
  7. Replies: 9
    Last Post: 04-01-2005, 05:06 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