Getting wrong value due to ref?

  • Thread starter Thread starter jesmin
  • Start date Start date
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
 
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
 
Back
Top