Results 1 to 6 of 6

Thread: [RESOLVED] Writing to cell error

  1. #1

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Resolved [RESOLVED] Writing to cell error

    Hope this is okay to post here, thought someone might know what the problem is.

    I'm writing a little VB macro in excel and I keep getting this error:
    "Object doesn't support this property or method"

    This is the first time I've written vb in excel so it's probably something really simple but my code seems okay:

    2 Code:
    1. currSheetName = ActiveWorkbook.Worksheets(I).Name       'Get current worksheet name (this is fine & works)
    2.  
    3. 'Output Results Here:  Get the ERROR here
    4. ActiveWorkbook.Worksheets(I).cell(100, 1).Value = currSheetName

    What am I doing wrong? Thanks,
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  2. #2
    Member
    Join Date
    Nov 2003
    Location
    Cambs, UK
    Posts
    55

    Re: Writing to cell error

    Assuming all you want to do is put the Sheet Name into a cell (eg A1):

    vb Code:
    1. ActiveWorkbook.Worksheets(I).Range("A1").Cells = currSheetName


    ~ James

  3. #3

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Writing to cell error

    There's more, it's actually in a loop so I need to keep specifying differnt cells as it loops. Everything else works, it's just the output that wont work. So close...Agghh!
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  4. #4
    Member
    Join Date
    Nov 2003
    Location
    Cambs, UK
    Posts
    55

    Re: Writing to cell error

    How do you calculate which cell it has to go in?

    It shouldn't matter if you're using different cells each time - just replace "A1" with a variable.

    Sorry if I'm completely missing the point!


    ~ James

  5. #5

    Thread Starter
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: Writing to cell error

    You know, that will do just fine. Actually more than fine. Thanks!

    Just out of curiosty, is the line I posted simply wrong and that's why it doesn't work or should it work?? Doesn't matter if you aren't sure, I'm just wondering.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  6. #6
    Member
    Join Date
    Nov 2003
    Location
    Cambs, UK
    Posts
    55

    Re: [RESOLVED] Writing to cell error

    Fantastic

    I'm no expert, but I've not seen

    vb Code:
    1. cell(100, 1).Value

    used before.

    I tend to record a Macro if I'm unsure how to do something (EG if I want to replace the contents of a cell, I'll run a macro and manually do that; then look at the code and do it that way in the future).

    As I said though, I'm far from an expert, so you may have been close doing it that way!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width