+ Reply to Thread
Results 1 to 7 of 7

Dim As Sting or Integer - Numbers and Fractions

Hybrid View

box-o-rocks Dim As Sting or Integer -... 08-05-2021, 10:06 AM
XLent Re: Dim As .... 08-05-2021, 10:37 AM
box-o-rocks Re: Dim As .... 08-05-2021, 10:42 AM
alansidman Re: Dim As .... 08-05-2021, 10:40 AM
alansidman Re: Dim As .... 08-05-2021, 11:20 AM
box-o-rocks Re: Dim As .... 08-05-2021, 11:26 AM
alansidman Re: Dim As .... 08-05-2021, 11:29 AM
  1. #1
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Dim As Sting or Integer - Numbers and Fractions

    I don't think I will need to post code to answer this question...


    I have a list of cells with numbers and fractions. Excel doesn't like fractions so I had to format those cells a "Text". In VBA if I assigned Dim x As String, Application.WorksheetFunction.Vlookup recogonizes the "fractions" but not the numbers. If I assigned Dim x As Integer, Application.WorksheetFunction.Vlookup recogonizes the numbers.... this is kind of understandable.

    Which Dim As should I use to be able to read all variables in the list?
    Last edited by box-o-rocks; 08-05-2021 at 11:29 AM. Reason: Moderator's request

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Dim As ....

    It's not clear where you're defining your lookup value but I would think you can leave this as a Variant

    Formula: copy to clipboard
    Dim x
    x = "1/2" 'or x=10
    MsgBox Application.WorksheetFunction(x,Sheets("Sheet1").Range("A:B"),2,0), vbInformation
    that said, you mention Excel doesn't like Fractions -- to my mind it doesn't mind them, you can use the Fraction number format.

  3. #3
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Re: Dim As ....

    Quote Originally Posted by XLent View Post
    It's not clear where you're defining your lookup value but I would think you can leave this as a Variant

    Formula: copy to clipboard
    Dim x
    x = "1/2" 'or x=10
    MsgBox Application.WorksheetFunction(x,Sheets("Sheet1").Range("A:B"),2,0), vbInformation
    that said, you mention Excel doesn't like Fractions -- to my mind it doesn't mind them, you can use the Fraction number format.
    When I use the Fraction number format, Excel changes it back to a date. According to Microsoft, they said the fix to that problem was to use the Text format

    I am using the variable to represent a textbox value.
    so, x = textbox.value

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,709

    Re: Dim As ....

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,709

    Re: Dim As ....

    Administrative Note:

    Welcome to the forum.

    Sorry, but your post does not comply with Rule #6 of our Forum RULES:

    Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction, then send a private message to them asking for clarification.

    All Participants:

    Please do not post a reply in a thread where a Moderator or Administrator has requested an action that has not yet been complied with (e.g. title change, code tags requested, etc.). Thanks.

  6. #6
    Registered User
    Join Date
    04-05-2021
    Location
    New York
    MS-Off Ver
    2013
    Posts
    15

    Re: Dim As ....

    Quote Originally Posted by alansidman View Post
    Administrative Note:

    Welcome to the forum.

    Sorry, but your post does not comply with Rule #6 of our Forum RULES:

    Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction, then send a private message to them asking for clarification.

    All Participants:

    Please do not post a reply in a thread where a Moderator or Administrator has requested an action that has not yet been complied with (e.g. title change, code tags requested, etc.). Thanks.
    I'm sorry. My reply was in progress while your post was coming through.

    I changed the thread Tag as requested, but it does not seem to have changed.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,709

    Re: Dim As ....

    To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.
    From my earlier post

+ 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