Getting wrong value due to ref?

J

jesmin

Hi Anyone:
I have 2 worksheets.
Sheet1:
-----Col:
RN:-A--B--C---D
1----2--4--""---8

Cell C1 has a blank data. I want to copy this data into sheet2 startin
from colB to colE at row num 5 as follows. The blank data to be replace
by 0.
Sheet2:
-----Col:
RN:-A--B--C--D--E
5-------2---4--0--8

I wrote down in VB:
Sheets("Sheet2).Range("B5:E5).Valu
="=If('Sheet1'!A1:D1="""",0,'Sheet1'!A1:D1)"

--Why the code is giving wrong results.

Thanks a lot for any help
 
G

George

You have missed a few quote marks (after Sheet2 and B5:E5)
And you dont need the A1:D1 just the A1,
Excel will adjust the formula as it copies across

Try this:
Sheets("Sheet2").Range("B5:E5").Value = _
"=If('Sheet1'!A1="""",0,'Sheet1'!A1)"

George
 

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