> Hey Otto, sorry for the confusion.
>
[quoted text clipped - 59 lines]
>> > know.
>> > Thanks.
Thanks Otto, this macro is exactly what I need. The last thing I need help
with is that the 7 cells (used to be 6, I had to add one) with the results
need to be moved and I don't know macros well enough to rewrite it. Let me
give you the exact cells where the results of table 1 and table 2 are where I
want the end results to be, if that helps.
Table 1 result cells: C104, C107, C111, C112, C119, C122, C125
Table 2 result cells: G104, G107, G111, G112, G119, G122, G125
Final result cells: N8, O8, P8, Q8, N10, O10, P10
The results need to be in this order as each cell represents something
different. For example, the C104 or G104 cell (depending on which table is
used) corresponds to the N8 result cell, C107 or G107 corresponds to the O8
result cell, and so forth.
Thanks again.
> Peter
> Here is a little macro that will do what you want. As written, the
[quoted text clipped - 98 lines]
> >> > know.
> >> > Thanks.
Otto Moehrbach - 25 Apr 2008 22:28 GMT
Peter
It doesn't matter how many cells there are in the results of each table.
The macro works with the named range, be it one cell or 1000 cells. You
simply select the cells and name the range. Now, your actual Table X result
cells are not contiguous, so you have to know how to select a non-contiguous
set of cells. Do you? Here's how. Click on the first cell, say C104.
Make sure that you don't hold the Ctrl key down until AFTER you have
selected that first cell. Now hold the Ctrl key down and click on each of
the remaining cells of that group. Release the Ctrl key. Ignore the fact
that the first cell you selected is not the same color as the rest of them.
Now click on Insert (in the menu at the top of the screen) - Name - Define.
Type in "Table1Results" without the quotes.
Now do the same thing with the Table 2 result cells. Don't forget to NOT
hold down the Ctrl key until after you have selected the first cell. Name
that group "Table2Results".
Because the destination cells (Final result cells) are also not contiguous,
I'll have to change the code to place the results where you want them and
will send you the finished macro. One question I have is what cell do you
want to use as the trigger to fire this thing? In the macro I sent you
before that was the cell above the first of the final result cells. That
may not be viable now, so tell me what cell you want to use. Otto
> Thanks Otto, this macro is exactly what I need. The last thing I need help
> with is that the 7 cells (used to be 6, I had to add one) with the results
[quoted text clipped - 132 lines]
>> >> > know.
>> >> > Thanks.
Otto Moehrbach - 25 Apr 2008 22:28 GMT
Peter
It doesn't matter how many cells there are in the results of each table.
The macro works with the named range, be it one cell or 1000 cells. You
simply select the cells and name the range. Now, your actual Table X result
cells are not contiguous, so you have to know how to select a non-contiguous
set of cells. Do you? Here's how. Click on the first cell, say C104.
Make sure that you don't hold the Ctrl key down until AFTER you have
selected that first cell. Now hold the Ctrl key down and click on each of
the remaining cells of that group. Release the Ctrl key. Ignore the fact
that the first cell you selected is not the same color as the rest of them.
Now click on Insert (in the menu at the top of the screen) - Name - Define.
Type in "Table1Results" without the quotes.
Now do the same thing with the Table 2 result cells. Don't forget to NOT
hold down the Ctrl key until after you have selected the first cell. Name
that group "Table2Results".
Because the destination cells (Final result cells) are also not contiguous,
I'll have to change the code to place the results where you want them and
will send you the finished macro. One question I have is what cell do you
want to use as the trigger to fire this thing? In the macro I sent you
before that was the cell above the first of the final result cells. That
may not be viable now, so tell me what cell you want to use. Otto
> Thanks Otto, this macro is exactly what I need. The last thing I need help
> with is that the 7 cells (used to be 6, I had to add one) with the results
[quoted text clipped - 132 lines]
>> >> > know.
>> >> > Thanks.
Peter - 25 Apr 2008 22:44 GMT
Hey Otto, the trigger cell I want to use is Q21
Thanks.
> Peter
> It doesn't matter how many cells there are in the results of each table.
[quoted text clipped - 153 lines]
> >> >> > know.
> >> >> > Thanks.
Otto Moehrbach - 27 Apr 2008 13:10 GMT
Peter
Here are the 2 macros you need. Place them both in the sheet module of
your sheet as before. Delete the previous macros.
You need to name 2 ranges. The first is the range of result cells for Table
1. Name this range Table1Results as before. Be sure that you include ONLY
the 7 cells that hold the Table 1 results.
Do the same for the Table 2 results and name that range Table2Results.
Delete any other range names that I previously told you to use.
Here is how it works:
If Q21 is empty and you click in that cell, you will get the Table 2 results
in the final result cells, and you will get "Table 2" in Q21.
You will notice that Q21 will contain only "Table 1" or "Table 2" or be
blank. The blank is the initial condition, After you first click in Q21, it
will contain only one of the 2 table references.
If you click in Q21 when Q21 is occupied, you will get the other table
reference in Q21 and the corresponding result cell values in the final
result cells.
Post back if you need more. HTH Otto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("Q21")) Is Nothing Then
Application.ScreenUpdating = False
Application.EnableEvents = False
If Target.Value = "Table 1" Or _
IsEmpty(Target.Value) Then
Range("Q21").Value = "Table 2"
Call CopyPaste(Range("Table2Results"))
Else
Range("Q21").Value = "Table 1"
Call CopyPaste(Range("Table1Results"))
End If
Range("Q22").Select
Application.EnableEvents = True
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
End Sub
Sub CopyPaste(TheTableRng As Range)
Dim i As Range
Dim Dest As Range
For Each i In TheTableRng
Select Case i.Address(0, 0)
Case "C104", "G104": Set Dest = Range("N8")
Case "C107", "G107": Set Dest = Range("O8")
Case "C111", "G111": Set Dest = Range("P8")
Case "C112", "G112": Set Dest = Range("Q8")
Case "C119", "G119": Set Dest = Range("N10")
Case "C122", "G122": Set Dest = Range("O10")
Case "C125", "G125": Set Dest = Range("P10")
End Select
i.Copy Dest
Next i
End Sub
> Hey Otto, the trigger cell I want to use is Q21
>
[quoted text clipped - 198 lines]
>> >> >> > know.
>> >> >> > Thanks.
Peter - 28 Apr 2008 17:52 GMT
That did it! Thanks for all of your help Otto.
> Peter
> Here are the 2 macros you need. Place them both in the sheet module of
[quoted text clipped - 253 lines]
> >> >> >> > know.
> >> >> >> > Thanks.
Otto Moehrbach - 28 Apr 2008 22:43 GMT
You're welcome. Thanks for the feedback. Otto
> That did it! Thanks for all of your help Otto.
>
[quoted text clipped - 286 lines]
>> >> >> >> > know.
>> >> >> >> > Thanks.