View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default Copy Data on click event

Ken
Something like this perhaps. I assumed the cell that gets the selected cell
contents is A1 and the cell that gets the string constant is B1. I also
assumed your table went from A2 to H100. Change these as needed. Be aware
that this macro will do its thing if you click on any cell in that range.
This macro is a sheet event macro and must be placed in the sheet module for
that sheet you want this to work in. To access that module, right-click on
the sheet tab and select View Code. Paste this macro into that module. "X"
out of the module to return to your sheet. Otto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim StrConst As String
If Target.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A2:H100")) Is Nothing Then
Range("A1").Value = Target.Value
Select Case Target.Column
Case 1: StrConst = "Whatever One"
Case 2: StrConst = "Whatever Two"
Case 3: StrConst = "Whatever Three"
Case 4: StrConst = "Whatever Four"
Case 5: StrConst = "Whatever Five"
Case 6: StrConst = "Whatever Six"
Case 7: StrConst = "Whatever Seven"
Case 8: StrConst = "Whatever Eight"
End Select
Range("B1").Value = StrConst
End If
End Sub
"Ken Broten" wrote in message
...
tI have a need to click on a cell containing a text string then have the
string copied to another cell and a 2nd cell set to a different value.

I have a table of string values. I want to click on any cell in the 1 st
column and have the cell content copied to a single fixed location cell.
Then
I want a string constant set in a different cell. For the remaining
columns
in the table the action is the same except that the constant string set in
the 2nd target cell is different.

How do I do this?
--
Ken Broten



 
ExcelBanter Database Error
Database Error Database error
The ExcelBanter database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.excelbanter.com home page, then try to open another page.
  • Click the Back button to try another link.
The www.excelbanter.com forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.