+ Reply to Thread
Results 1 to 4 of 4

how to refer to a sheet properly

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    89

    how to refer to a sheet properly

    I have a line of code, it used to work fine, but after some smaller changes, its not doing it what i want it to do.

    HTML Code: 
    it is meant to tkae the value from the second sheet in wb2, and paste it into the sheet data in WB. however it is actually gathering data from the first sheet. any suggestions why ?

    edit: it works if i use: Sheets("Number of open orders") instead, but i was certain i could refer to the sheet nr aswell ?
    Last edited by siggisigg; 07-18-2014 at 04:17 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: how to refer to a sheet properly

    What have you set wb and wb2 to be?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: how to refer to a sheet properly

    Hi, siggisigg,

    me personally would prefer to fully qualifiy the name of the worksheet instead of using itīs position in a workbook as that may be different due to somebody dragging the sheet around. This one line of code out of the context looks good for me instead that I would add a .Value after the first part of the equation
    Please Login or Register  to view this content.
    Edit: You maybe should use Worksheets instead of Sheets as Sheets may as well be a chart as a worksheet.

    Ciao,
    Holger
    Last edited by HaHoBe; 07-18-2014 at 04:23 AM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    07-03-2013
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: how to refer to a sheet properly

    WB is the workbook im working in, WB2 is a chosen workbook to gather data from.

    HaHoBe:
    ah, ok. that might be the problem. i didnt realize it refered to the number according to when it was created. i rather thought it was what position it was in. that makes sence though. thanks!

+ 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. [SOLVED] Use INDIRECT To Refer Sheet Name
    By jackgan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-09-2014, 03:50 PM
  2. how to refer a sheet by its name
    By pankajy18 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-02-2013, 10:39 AM
  3. Replies: 7
    Last Post: 12-16-2012, 04:24 PM
  4. Replies: 2
    Last Post: 08-21-2012, 09:15 AM
  5. To refer certain value from other sheet
    By pastecopy in forum Excel General
    Replies: 2
    Last Post: 03-19-2011, 09:47 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