Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Simple Macro - I think... Copy - Paste on Click

Excel 2007
I have a workbook with 2 Sheets: Sheet1 and Sheet2

Sheet1 contains a list of all 50 states in column A

Goal: When any item in the cell in the list of 50 states is clicked on
Sheet 1, Cell A1 on Sheet2 will be populated with the contents of the cell
that is clicked.

Any suggestions?
Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Simple Macro - I think... Copy - Paste on Click

Hi,
Try this code into sheet1 in the VBA window:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("Sheet2").Range("A1") = ActiveCell
End Sub

Regards - Dave.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Simple Macro - I think... Copy - Paste on Click

Dave, thanks for this reply. The code works quite well.

I would like to enhance it as follows:

1. Is there a way to limit this to just column A? So if I click somewhere
in column B Sheet2!A1 does not change

2. Limit it to only a double click

3. After clicking, it will jump to cell A1 on Sheet2

Thanks again



"Dave" wrote:

Hi,
Try this code into sheet1 in the VBA window:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("Sheet2").Range("A1") = ActiveCell
End Sub

Regards - Dave.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Simple Macro - I think... Copy - Paste on Click

Hi Scott,
Try this

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.Column = 1 Then
Sheets("Sheet2").Range("A1") = ActiveCell
Sheets("Sheet2").Select
End If
End Sub


You may have to unwrap the first line if it gets wrapped by this window.

Regards - Dave


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Simple Macro - I think... Copy - Paste on Click

Thanks Dave. It worked out perfect.

"Dave" wrote:

Hi Scott,
Try this

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.Column = 1 Then
Sheets("Sheet2").Range("A1") = ActiveCell
Sheets("Sheet2").Select
End If
End Sub


You may have to unwrap the first line if it gets wrapped by this window.

Regards - Dave




  #6   Report Post  
Junior Member
 
Posts: 1
Default

How do you use this macro? just copy this to Visual basic?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and Paste using macro [email protected] Excel Discussion (Misc queries) 0 February 8th 07 09:47 AM
How to write a simple copy-paste macro? R. H. Rosenberg New Users to Excel 4 November 25th 06 12:26 AM
HELP with macro for copy and paste RedOctagon Excel Discussion (Misc queries) 0 October 13th 06 02:54 PM
How to restore right click functionality for copy and paste? duncansk Excel Discussion (Misc queries) 3 August 11th 05 12:39 PM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"