Dubzmeister
Dubzmeister

Reputation: 35

Excel input and output into same cell

I searched online for a solution but nothing came up. All the answers were for single targets cells.

The thing I want to do is the following, in Range L1:L1000 if I input something into a cell in this range then it gets added to the following formula =IF(N1=0;"";INPUT) - in the same cell.

So lets say I type Hello into L1 then the formula becomes =IF(N1=0;"";"Hello")

If anyone could help me that would be awesome since my understanding of VB is very very basic and I am just learning it.

Upvotes: 2

Views: 941

Answers (1)

user11909
user11909

Reputation: 1265

You can use an event when the cell is changed:

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False

    If (Not Intersect(Target, Range("L1:L1000")) Is Nothing) Then
         'E.g.: Here comes your code for Cell L1
          Target.Formula = "=IF(N1=0,""""," & Target.Text & ")"
    End If 

    Application.EnableEvents = True
End Sub

This method sets the formular of the edited cell to =IF(N1=0;"";INPUT).

Upvotes: 2

Related Questions