Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is Multi click Event possible? | Excel Discussion (Misc queries) | |||
ListBox Click Event | Excel Discussion (Misc queries) | |||
On click button event | Excel Worksheet Functions | |||
Click event for checkbox from Forms toolbar | Excel Discussion (Misc queries) | |||
call a function on control click event | Excel Discussion (Misc queries) |