I'm new with VB coding in Excel and would like to know how if I can click on a particular cell and have that cell loaded with the value of another cell with a single click. For example, if the value “SVE” is in cell AP1, how can I click on the blank cell B8 and have “SVE” loaded into B8 in a single click without typing the value “SVE” prior to clicking on the cell? Does it require a formula or does it have to be done with VBA code?
Developer > Visual Basic
to open the Visual Basic Editor. Open View > Project Explorer
. Double-click on your project (VBAProject(YourWorkbookName.xlsm
)) and double-click the worksheet (e.g. Sheet1(Data)
) where you need the requirement. Into the newly opened sheet module window, copy/paste the following code:Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("B8"), Target) Is Nothing Then Exit Sub
Target.Value = Range("AP1").Value
End Sub