+ Reply to Thread
Results 1 to 3 of 3

variable or with block variable not set

Hybrid View

  1. #1
    Registered User
    Join Date
    06-04-2008
    Posts
    14

    variable or with block variable not set

    Hi all,

    I'm having two problems with a program that I'm writing and I'm wondering if you could help me out:

    1) In the following code, I have a collection of "Group" objects stored in "groups". I want to make a temp Group object to store an item from the collection. However, on the 2nd line below I keep getting: "Object variable or with block variable not set".

       
    
    Dim currentGroup As Group
    currentGroup = groups.Item(counter2)
    2) I'm trying to retrieve an item from a variant array and convert it to an int using CInt, however on the fifth line below I get the error: "Type Mismatch"

    
    Dim currentBit As Integer
    Dim lineBits As Variant
    Line Input #filePathNumber, lineString
    lineBits = Split(lineString, ",")
    currentBit = CInt(lineBits(bitCount))
    Any help would be appreciated thanks.

    KiSS
    Last edited by VBA Noob; 10-15-2008 at 04:16 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello kissfrito,

    In your first question, you define a variable as the type Group. Unless you have defined Group yourself as a UDT (User Defined Type), I am unaware of any such object type. This why you get the error.

    In your second question, you are coercing a data type, presumably a string, into an integer. I don't see where you have assigned a value to bitCount. Also, if there is no comma present in lineString the Split function will return all of lineString. So, if bitCount exceeds the number of commas found or there are no commas present and lineString can not be evaluated to a number then you will get an error.

    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Leith,

    He may not respond as this is a cross post

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ 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. Error 91 - Object variable or with block variable not set
    By jaiswati in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-10-2012, 11:44 AM
  2. Error 91:“Object Variable or With Block Variable not set”.
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2007, 08:44 AM
  3. Error: "Object Variable or With Block variable not set"
    By aziraphale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2007, 06:14 PM
  4. Object Variable or with Block Variable not set Error
    By Jen_DPS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2006, 03:15 PM
  5. Error 91, Object Variable or With Block variable not set.
    By AMK4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2006, 11:38 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