Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50121

Please help on this simple macro code

$
0
0
The macro below is adapted from a post in this discussion forum. It is used to set the value in cell E1, when the other cell F1 (a list) is selected ("Last reported figure", "Average of last 3Y", or "Manual input".

I am wondering if this can be further adapted so that: instead of controlling the value E1 by F1, can we move the control directly to cell E1? That is, if someone click cell E1 and select, say, "Last reported figure", then E1 will have a numeric value equal to A1 in sheet DCF :confused:

Code:

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("F1")) Is Nothing Then

    Select Case Target.Value
   
        Case Is = "Last reported figure"
       
            Range("E1").Value = ThisWorkbook.Sheets("DCF").Range("A1")
         
        Case Is = "Average of last 3Y"
       
            Range("E1").Value = ThisWorkbook.Sheets("DCF").Range("A2")
           
        Case Is = "Manual input"
       
            Range("E1") = InputBox("Please Enter Manually")
           
    End Select
   
End If

End Sub


Viewing all articles
Browse latest Browse all 50121

Trending Articles