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
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Derek

Well-known Member
Joined
Feb 16, 2002
Messages
1,592
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,082
Messages
5,570,095
Members
412,311
Latest member
Mozz
Top