Help with auto populating cells

GodsDsipl

New Member
Joined
Dec 29, 2005
Messages
7
I am creating a materials costing sheet and I need to know how to have excel populate two cells with a number when you put a number in another cell. This is what I was thinking...

if you enter 1 in to cell A! the excel will put the number 6 in A2 and the number 12in A3

=if(A1="1" then A2="6", A3=12)

:confused: Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi there

You need to put your formula in the cells that will show the answer.
In A2 you need:
=IF(A1=1,6,0)
and in A3 you need:
=IF(A1=1,12,0)

If you do not wish these cells to display 0 when A1 does not contain 1 then you should custom format A2 and A3 as General;;

If you do not want to use formulas, you can trigger this by using an event macro. Go to the VB Editor (right click sheet tab, left click View Code) and paste this code into the large code window:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" Then Exit Sub
If Target.Address = "$A$1" And Target.Value = 1 Then
[a2].Value = 6
[a3].Value = 12
Else
[a2:a3].ClearContents
End If
End Sub

Close all windows to return to your worksheet

regards
Derek
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top