Not able to put column location from one worksheet to another

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
299
Office Version
  1. 365
When a user double-clicks on a cell in one worksheet (on row 10), I want to put the location of that column in F3 on another worksheet.


Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
 Cancel = True
  If Target.Column > 2 And Target.Row = 10 Then
   Dim c As Long
   c = Worksheets("Deliverables").ActiveCell.Column
   Worksheets("Deliverables Prep").Range("F3") = c
  End If
 End Sub
So if the user double-clicks on a cell in row 10, column 5 on "Deliverables", I want 5 to go into F3 on "Deliverables Prep".


But when I execute the above code, I get this error message, "Object doesn't support this property or method."


I've even tried this code, but without success:


Code:
Worksheets("Deliverables Prep").Range("F3") = Worksheets("Deliverables").ActiveCell.Column
What am I missing please?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You cannot copy an entire column & then paste it starting in row 3.
Either copy to F1, or only copy the used range.
 
Upvote 0
No need to use "ActiveCell". Target is the ActiveCell that triggered the code to run.

Try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    Dim c As Long
    
    Cancel = True
  
    If Target.Column > 2 And Target.Row = 10 Then
        c = Target.Column
        Worksheets("Deliverables Prep").Range("F3") = c
    End If
    
 End Sub
 
Upvote 0
Try
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
 Cancel = True
  If Target.Column > 2 And Target.Row = 10 Then
   Dim c As Long
   c = Target.Column
   Worksheets("Deliverables Prep").Range("F3") = c
  End If
 End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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