Consulting

Results 1 to 6 of 6

Thread: Solved: resetting a variable to empty

  1. #1

    Solved: resetting a variable to empty

    I decared it and gave it a value, but for certain loops I need it to be empty.

    If I have

    Dim somenumber As integer
    somenumber = 5

    'now I want to make it empty.

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    somenumber = 0

  3. #3
    Not too sure what you mean by "empty", but you might use:

    somenumber = vbNullString
    or vbNullValue (I think there is such a thing ... see Help)
    Sid

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Why do you need the variable to be empty?

    In fact why do you need it anyway.

    Sid

    I can't find a vbNullValue in the Object Browser or Help.

    Did you?

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Quote Originally Posted by Norie
    Why do you need the variable to be empty?

    In fact why do you need it anyway.
    For something as simple as this, I don't think reasons are required, just a solution. Wouldn't that be more productive?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Malcolm

    I sort of agree but I don't quite get what you mean by simplicity.

    The OP has only posted this question, but they've not actually said what they actually want to do.

    The original question could be addressed in several ways, including those suggested by yourself and others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •