In VBA what's the best way to link one cell to another cell without normal references/formulas?

In my current sheet I am trying to make cell F7 determine what goes in cell B17, but I don't want to use formulas. I want my user to select a date from a dropdown in cell F7, and have the macro put that same date value into B17. Using VBA, what's the fastest, most efficient way to achieve this? I wrote the code below but it seems to be slowing all my other macros down.


Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    

    If Range("F7").Value <> Range("B17").Value And ActiveCell.Address = "$F$7" Then
        Application.EnableEvents = False
        ActiveSheet.Range("B17").Value = ActiveSheet.Range("F7").Value
        Application.EnableEvents = True
    End If
    Application.EnableEvents = True
    
End Sub

Open in new window

shampouyaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne Taylor (webtubbs)Commented:
Try using the Change event instead...

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, [F7]) Is Nothing Then
        Application.EnableEvents = False
        Range("B17").Value = Range("F7").Value
        Application.EnableEvents = True
    End If
End Sub

Open in new window


BTW, you don't need to use ActiveSheet as it's always assumed when omitted.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rob HensonFinance AnalystCommented:
Any particular reason for not just putting the formula in B17:

=F7

Or just put the Date Picker in B17.

What are you trying to achieve?

Thanks
Rob H
FarWestCommented:
@Rob Henson,
I don't know about  shampouya
for me I need such thing sometimes when cell value B17 in this case will have default values and the user can change, if there is a formula then it will be removed if the user edited it with a value
so he can select a date from predefined dates (for example quarter start date) or choose any other date
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

shampouyaAuthor Commented:
What does line 2 mean exactly in Wayne Taylor's code in the first post? Can someone explain that to me?

 
 If Not Intersect(Target, [F7]) Is Nothing Then
Wayne Taylor (webtubbs)Commented:
Basically it's checking that the Target cell (the cell whose value changed) is F7. It does the same as you checking the address - it's just how I do it :)

 You can also use Intersect to check that the Target is within a range of cells.
shampouyaAuthor Commented:
Superb Wayne. Thanks so much, really improved the performance of my code.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.