I have got a syntx error on the lineCould you please help?![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
I have got a syntx error on the lineCould you please help?![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Hi,
The code looks fine to me. is it possible that you have also chart sheets in your workbook? However in this case it will not be a syntax error...
Buran
If you are pleased with a member's answer then use the Star icon to rate it.
Also, check that you don't have empty G2 cell and that values in the G2 cells are allowed for worksheet name - there are some characters that are not allowed in the worksheet name.
The code works fine when only worksheets in the workbook and all G2 are not empty
Buran
Buran! Thanks!, No I do not have charts. Actually, I have created a new sheet with values in G2 to test it, but still shows error 1004 " Method name of object_worksheet failed
Can you upload your sample workbook? You can find my sample workbook and your code works just fine in it.
Buran! Thanks!
When I put your code in to my personal workbook modules code, I had the same error, but when I created a new sheet and put the code in to new module, it works. Very strange!
If it is in your personal workbook, then ThisWorkbook refers to it, not the active workbook. So what you are doing is that you loop trough sheets in active workbook and for the name of first worksheet in the active workbook, you try to read g2 value from the first sheet in the personal workbook (most probably empty cell). I assume that another problem would be different number of sheets in the two workbooks
like buran said I reckon you meant
or easier![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Josie
if at first you don't succeed try doing it the way your wife told you to
JosephP and Buran! Thanks you very much for your time and help!
JosephP! I am glad you are becoming my mentor on this site. You included my favourite loop code as alternative.
You are probably right! "Probably" because I am still novice to VBA and do not understand what I am doing, so will accept your arguments. What is interesting is though I had similar issued before with personal workbook modules and did not check if my code was referring to particular sheet, or active sheet, but I did not know the issue then. This shows that you never stop learning on this site.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks