Strange Prob with Worksheet name

J

jesmin

Hi There:
In my workbook, name of 2 worksheets are a_data & a_report. I a
getting correct result when I am using the following in another tria
sheet:
Sheets("Sheet2").Cells(1,1).Formula="=SUMIF(Sheet1 !A:A,0,Sheet1!B:B)"

But when I am using my original workbook code with the original name a
follows, its giving run-time error.:
Sheets("a_report").Cells(1,1).Formula="=SUMIF(a_d
ta!A:A,0,a_data!B:B)"

--why the reference creating problem when I am chanhging just the shee
name from Shee1 to a_data.
Thanks in advance
 
D

Dave Peterson

Your code worked ok for me when I had two sheets named a_data and a_report.

But if the names were different (leading/trailing spaces), then it didn't work.

Just a guess. Does that underscore really mean an underscore--or is a way of
showing a space character.

If you really have "a data" and "a report", try:

Sheets("a report").Cells(1, 1).Formula = "=SUMIF('a data'!A:A,0,'a data'!B:B)"

In fact, those extra apostrophes in the formula won't matter to excel if you
don't actually need them.

If that's not it, try renaming the sheet one more time. And be careful with
those leading/trailing spaces.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top