Results 1 to 18 of 18

Avoiding Variants: Multiple Declarations per Line Assign Variants To All But Last Variable

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Avoiding Variants: Multiple Declarations per Line Assign Variants To All But Last Variable

    When I declare a set of variables in Microsoft Excel's VBA Version 15.0 as such:
    Option Explicit
    Sub MyCode()
    Dim i, j, k As Integer
    .
    '/Code Goes Here
    .
    End Sub
    ...I notice in my Locals Window that i & j (or any variables except the last variable declared as any datatype) are variants; however, k is declared as type: Integer.

    When I step through my code, I see i & j change from: Variant/Empty to Variant/Integer as I assign integers to i & j. Since they're variants, I can also assign other datatypes to i & j.

    QUESTION: Is there any way to declare multiple variables per line of the same datatype without a long-winded: Dim i As Integer, j As Integer, k As Integer?

    I thought Dim i, j, k As Integer declared all i, j, and k as Integers and now I'm about 10,000 lines deep into a project I'd rather not retrace through for that. Hoping for some kind of Application.Magic command.

    Thanks in advance,

    Joe
    Last edited by joe31623; 12-05-2015 at 01:48 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Setting an object using multiple variants
    By knitterkuba in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2015, 04:36 AM
  2. Variants of csv file
    By jywll in forum Excel General
    Replies: 0
    Last Post: 02-18-2014, 05:26 PM
  3. [SOLVED] Excel 2007 : Sumifs with Multiple variants
    By ncurran217 in forum Excel General
    Replies: 1
    Last Post: 04-20-2012, 11:06 AM
  4. [SOLVED] Searching for multiple names and variants
    By CFlack8472 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2012, 08:30 PM
  5. Write text to multiple cells using variants
    By therealjag in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-18-2009, 10:56 AM
  6. Use of Variants
    By rwgrietveld in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-14-2008, 08:44 AM
  7. [SOLVED] Variants vs ranges
    By joejohnsonatl45@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2005, 08:25 AM

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