Moving Cell Values

  • Thread starter Thread starter Stella
  • Start date Start date
S

Stella

I want to write a simple macro using If...... in a For...Next loop in
which I transfer a cell value depending on the If test. However I can only
seem to move the cells' formulae and not their values.

E.G.

* If A1 = 0 then the value in B1 must be made to equal the value in B2 and
so on*

For x = 1 to 10
If Cells(x,1) = 0 Then
Cells(x,2) = Cells(x+1,2)
Endif

Next x

How do transfer the values in col B and not the formulae?


TIA
Stella
 
Hi Stella,

For me, your code works as you indicate that you wish it to work: values
rather than formulae are copied into the relevant column B cells.

Could you give an example of your data and the problematic results?
 
2 points Stella,

The first, to make sure you are talking and moving values use the code
....

For x = 1 to 10
If Cells(x,1).Value = 0 Then
Cells(x,2).Value = Cells(x+1,2).Value
Endif

But secondly, just check that the number format of the object cell
isn't set to TEXT.

Alan
 

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

Back
Top