+ Reply to Thread
Results 1 to 3 of 3

Vba code to return a value

  1. #1
    Registered User
    Join Date
    05-01-2004
    Posts
    8

    Question Vba code to return a value

    I want to populate a Listbox with the value of a cell of a worksheet in the the same workbook.
    this is what I have

    Sub Populateselldays()
    lb04selldays = Sheets("selling")("c2").Value
    End Sub

    "Selling" is the name of the worksheet and the value I want is in c2.
    "lb04selldays" is the name of the list box

    I call the sub on initialize but it gives me errors.
    Any thought on how this can be done?
    Last edited by eklarsen; 02-25-2005 at 08:53 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 EKLarsen,

    Make these changes and the code will work.

    Sub Populateselldays()
    lb04selldays.AddItem Sheets("selling").Range("C2").Value
    End Sub


    Best wishes,
    Leith Ross

  3. #3
    Registered User
    Join Date
    05-01-2004
    Posts
    8

    Thanks

    It worked perfectly thank you.
    Sorry for being such a newbie

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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