Case Select VBA Depending on cell i click

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
This is my current code
I don't know where to put this code but i have it undr Sheet1 tab (View Code)
here is what I am have there

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     
    Select Case Target.Address
         
    Case "$A$11"
        Sheets("Sheet2").Select
        Range("A2").Select
        ActiveCell.FormulaR1C1 = Range("S12")
        
    Case "A12"
               Sheets("Sheet2").Select
        Range("A2").Select
        ActiveCell.FormulaR1C1 = Range("S13")
    
     Case "$B$21"
               Sheets("Sheet3").Select
        Range("A2").Select
        ActiveCell.FormulaR1C1 = Range("S2")
    End Select
End Sub
if user click's on Cell C11 on sheet1, in Sheet2 Cell A1 it will type some formula or take the range of S2
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you have it in Sheet1 code, it will function on Sheet1.

But there is no need to do all that Selecting:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
     
    Select Case Target.Address(0, 0)
         
    Case "A11"
        Sheets("Sheet2").Range("A2") = Range("S12")
        
    Case "A12"
        Sheets("Sheet2").Range("A2") = Range("S13")
    
     Case "B21"
        Sheets("Sheet3").Range("A2") = Range("S2")
    End Select
End Sub
You will need to clarify what you mean by that last sentence. What is the condition for either putting in a formula or the value from S2?
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top