# I need a formula in one cell to put data in a different cell.

#### GreasySpot

##### New Member
I need a formula in one cell to put data in a different cell.
example:

a1 value is 1000
a2 value is empty

I want a formula in a3 to read the value of a2. If it has a value then do nothing. If it is empty then make the value of a2=a1.

Simple right?

### Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
in A3
=IF(A2<>"",A1,"")

I don't want a value in a3 I want it to be in a2.

Because you are manipulating values in A2 you cannot use a formula to do this. You will need to use a VBA solution.

If you want the values to appear in A3, then you could use this formula

=if(A2<>"",A2, A1). This would appear in A3

Your VBA solution would be as follows

Code:
``````Option Explicit

Sub foo()

If IsNull(Range("A2")) Then
Range("A2").Value = Range("A1").Value
End If

End Sub``````

I need a formula in one cell to put data in a different cell.
example:

a1 value is 1000
a2 value is empty

I want a formula in a3 to read the value of a2. If it has a value then do nothing. If it is empty then make the value of a2=a1.

Simple right?

You need to explain clearly what you want.

Because you are manipulating values in A2 you cannot use a formula to do this. You will need to use a VBA solution.

If you want the values to appear in A3, then you could use this formula

=if(A2<>"",A2, A1). This would appear in A3

Your VBA solution would be as follows

Code:
``````Option Explicit

Sub foo()

If IsNull(Range("A2")) Then
Range("A2").Value = Range("A1").Value
End If

End Sub``````

This looks good alan. Thanks.

My excel file has 7 sheets, 1 for each day of the week. On each sheet I have 2 cells where I need this code to apply. Does this code need to be specific for each instance or sheet?

Thanks again,

You can open each sheet and run the code or you can use the following to run it once and it will update all seven sheets.

Code:
``````Option Explicit
Sub foo()
Dim ws as worksheet
For each ws in worksheets
If IsNull(Range("A2")) Then
Range("A2").Value = Range("A1").Value
End If
Next ws
End sub``````

I got to looking harder at my workbook and realized I don't need to process every sheet just: Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday.

Replies
2
Views
123
Replies
7
Views
211
Replies
14
Views
387
Replies
2
Views
60
Replies
1
Views
63

1,203,638
Messages
6,056,481
Members
444,869
Latest member
tulo spont

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back