+ Reply to Thread
Results 1 to 12 of 12

Amend Code help

  1. #1
    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

    Amend Code help

    Hi,

    Using some of Ron's Code. I want to change this bit of code to look at first sheet regardless of Sheet name

    Please Login or Register  to view this content.

    tried this but didn't work
    Sheets("Sheet1")

    Any help appreciated

    VBA Noob

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Use: Sheets(1)


    HTH
    Col
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  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
    Get a run time error 438 when I change it

    VBA Noob

  4. #4
    Registered User
    Join Date
    09-20-2006
    Location
    Poland
    Posts
    46
    Hi,

    I am not sure if this helps, but if GetData requires a string variable with sheet tab name, try:

    Please Login or Register  to view this content.
    If it requires sheet code name try using Sheets(1).CodeName instead.
    MS Excel Games Library and much more:
    http://www.dzikosoft.com/gmexcel

  5. #5
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Sorry, my bad! Bartek is of course right.

    C

  6. #6
    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
    Thanks Guys.

    Will give it a go

    VBA Noob

  7. #7
    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
    Hi again,

    Still trying to modify this code.

    If I change it to Sheets(1).Name I get sheet name error messages.

    I then tried to pull off any sheet names called "New". Still get the error message if a sheet didn't have that name.

    tried on error resume next and application.displayalerts = false. Anyone got any ideas how to amend the code to either pull off worksheets called New or ideally the first sheet in the workbook regardless of name

    Many thanks

    VBA Noob

  8. #8
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Can you post a link to where you got the code on Rons site?

  9. #9
    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
    Sure,

    Here is the link. Thanks for taking a look at it for me

    http://www.rondebruin.nl/ado.htm#subfolders

    VBA Noob

  10. #10
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by VBA Noob
    Hi,

    Using some of Ron's Code. I want to change this bit of code to look at first sheet regardless of Sheet name

    Please Login or Register  to view this content.

    tried this but didn't work
    Sheets("Sheet1")

    Any help appreciated

    VBA Noob
    Hi,

    This just follows what everyone else has said but this works. Any clues in it that you could use?

    Public Sub FirstsheetInBook()
    'Uses 1st sheet positioned on the left in w/book
    'Uses by location, ignores given & code names.
    Sheets(1).Range("a1").Value = 300
    End Sub
    Thx
    Dave
    "The game is afoot Watson"

  11. #11
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    As the code is reading from the SourceFile workbook without opening it you'll need to know the name of the sheet beforehand - there's no way to check what it's called without opening the file to see (as far as I know, although I'm always happy to be proved wrong!)


    C

  12. #12
    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
    Thanks.

    I'm hoping your wrong thou.

    VBA noob

+ 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