How to change cell value based on input and other cell vlaues?

fahadun

New Member
Joined
Jul 27, 2017
Messages
22
hello,

I have a little problem. here is my sample excel data. its fairly large.
ABCDE
AAAAA1
AAABB2
nullnull3
BBBCC4
BBBDD5

<tbody>
</tbody>










So i want to change the values in column A and B. so i want to input a number (1-5) in column B and values of column A and B should change according to that number. For example if put 1 in B1, values of A1 should be AAA and value of B1 should be AA. again if i put 4 in b2 value of A2 should be BBB and value of B2 should be CC. How i can do that?
 

Some videos you may like

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
9,535
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a values in column B and exit the cell
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim foundVal As Range
    Set foundVal = Range("E:E").Find(Target, LookIn:=xlValues, lookat:=xlWhole)
    If Not foundVal Is Nothing Then
        Target = foundVal.Offset(0, -1)
        Target.Offset(0, -1) = foundVal.Offset(0, -2)
    End If
    Application.ScreenUpdating = True
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,768
Messages
5,524,787
Members
409,600
Latest member
Dunnowhatfor

This Week's Hot Topics

Top