[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:
currSheetName = ActiveWorkbook.Worksheets(I).Name 'Get current worksheet name (this is fine & works)
'Output Results Here: Get the ERROR here
ActiveWorkbook.Worksheets(I).cell(100, 1).Value = currSheetName
What am I doing wrong? Thanks,
Re: Writing to cell error
Assuming all you want to do is put the Sheet Name into a cell (eg A1):
vb Code:
ActiveWorkbook.Worksheets(I).Range("A1").Cells = currSheetName
~ James
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!
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
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.
Re: [RESOLVED] Writing to cell error
Fantastic :)
I'm no expert, but I've not seen
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!