+ Reply to Thread
Results 1 to 4 of 4

Assign number to variable in VBA?

  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Lexington, MA
    MS-Off Ver
    Excel 2007
    Posts
    9

    Assign number to variable in VBA?

    Hey guys,

    I'm having trouble assigning the value 2 to my x variable. I have a little bit of experience in C++ and none in VBA, so this is probably a stupid mistake. Here is my code:

    Please Login or Register  to view this content.
    Thanks guys.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Assign number to variable in VBA?

    There's nothing wrong with your assignment.

    In VBA, variables types should be declared appropriate to usage; e.g., if sourcecell is intended to be a range, it should be declared as a Range.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-04-2009
    Location
    Lexington, MA
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Assign number to variable in VBA?

    Thanks for the help, I replaced the "cells(x, 2)" with "range("B" & x)" and the program ran. Unfortunately, it gave me an overflow message. I do not think I am approaching this problem in the right method. Here is a link to my problem that I'm trying to solve. If anyone can help, it would mean the world. Thanks!

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Assign number to variable in VBA?

    I posted a suggested solution to your other thread. If it works, will it address this problem too?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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