Text in inputbox

  • Hi there


    I have this code here. But when I run it then the only thing I can right in the inputbox is numbers. But I want to write letters in the inputbox. What is wrong with the code?? :?


    Please someone help me.



    Alring

  • Re: Text in inputbox


    Sorry!!!!!


    Code
    With Ark1


    Should have been:


    Code
    With Sheet1


    The reason for the mistake is that my Excel is danish.


    Alring

  • Re: Text in inputbox


    Your Type is 1, which represents a number


    Here are the typres available to it


    Value Meaning
    0 A formula
    1 A number
    2 Text (a string)
    4 A logical value (True or False)
    8 A cell reference, as a Range object
    16 An error value, such as #N/A
    64 An array of values

  • Re: Text in inputbox


    In addition to the Type 1 fix that Will provided, you also should change the nat Dim to String

  • Re: Text in inputbox


    Hi Will


    When I try to run the macro with 2 instead of 1 then I get the message "Type mismatch"

  • Re: Text in inputbox


    Yeah, see Tom's post too - I missed that you'd also incorrectly dimensioned the nat variable as Long, which should be a String

  • Re: Text in inputbox


    Hi Thomach


    Thank you so much for your help. It works :thanx:


    I can see that you wrote in the beginning of the macro:


    Code
    Option Explicit


    I tried the macro without that code and then it didn't work. So what does that do with a macro??


    Alring

  • Re: Text in inputbox


    Hi Will


    Also thank you to you for your reply. :thanx:


    I was using Long because it was working with the numbers in another macro. Now I can see that I can use string no matter if it's letters or numbers. But I will remember the numbercodes you gave me.


    Alring

  • Re: Text in inputbox


    Option Explicit is used to force all variables to be declared with a Dim statement. Removing it should make the code more likely to run; it should not cause it to stop running. My guess is that you removed more then the "Option Explicit" characters ... but this is only a guess.

  • Re: Text in inputbox


    Hi thomach


    Thank you for your reply :thanx:


    I have tried to run the macro with and without Option Explicit and the macro works in both ways. The mistake I made with your code was still to have As long instead of As String.


    Alring

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!