VBA to refer to cell value of another worksheet:

SevenOut

Board Regular
Joined
Jan 7, 2020
Messages
82
Office Version
  1. 2013
Platform
  1. Windows
My workbook has worksheets for each month, a report sheet and a "Roster" sheet.

I currently have a macro that allows me to (while on a month worksheet such as 'January') double click a cell in range to auto enter "10".
I would like to alter this so when double clicking, instead of entering "10", the value of Roster!O11 is entered instead.
The code also allows me to double click the cell containing "10" to clear the value, so this would also need to refer to Roster!O11.
Any help would be much appreciated.

The following is the Worksheet code in its entirety:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("B3:AF29")) Is Nothing Then
    If Target.Value = "" Then
        Target.Value = "10"
        Target.Offset(1, 0).Select
    ElseIf Target.Value <> "" And Target.Value = "10" Then
        Target.Value = ""
        Target.Offset(1, 0).Select
    End If
End If
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I feel dumb. For each month, I referenced the cell on "Roster!O11". (AI1)
Changed the Target.Value = "10" to Target.Value = Range("AI1")
Problem solved.
 
Upvote 0

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

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