replacing array for a position number

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hello everyone.

I post this 3 days ago on ozgrid, and this is the post.(no answer).

The list at the left is the data (A1:F1900) in the middle the table (is like a parking lot - place number), and in the right is the swap results, I mean if I put the table in front of the list, and want to know what place number 2 was before, I can see was in the position 7 in the table, next #6 was in 8 and so on, see the example:
Code:
[TABLE="width: 653"]
<tbody>[TR]
[TD="class: xl63, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]25[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]31[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]37[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]50[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]1[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]2[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]3[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]4[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]5[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 33, bgcolor: transparent"][FONT=Calibri]7[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]8[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]28[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]52[/FONT]
[/TD]
[TD="class: xl64, width: 49, bgcolor: transparent"][FONT=Calibri]47[/FONT]
[/TD]
[TD="class: xl66, width: 49, bgcolor: transparent"][FONT=Calibri]etc.[/FONT]
[/TD]
[/TR]
[TR]
[TD="class: xl63, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]11[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]18[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]38[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]48[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]7[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]8[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]9[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]10[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]11[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]12[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]26[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]44[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]46[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]47[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]13[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]14[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]15[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]16[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]17[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]18[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]8[/COLOR][/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]14[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]26[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]33[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]51[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]19[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]20[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]21[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]23[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]24[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]5[/COLOR][/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]9[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]25[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]39[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]41[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]25[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]26[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]27[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]28[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]29[/FONT]
[/TD]
[TD="class: xl64, width: 41, bgcolor: transparent"][FONT=Calibri]30[/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl65, width: 49, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
when I go to swap the second line I mean 2-6-11-18-etc. the table has to move one cell down like this.
Code:
[TABLE="width: 653"]
<tbody>[TR]
[TD="class: xl65, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]25[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]31[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]37[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]50[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 33, bgcolor: transparent"][FONT=Calibri]7[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]8[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]28[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]52[/FONT]
[/TD]
[TD="class: xl66, width: 49, bgcolor: transparent"][FONT=Calibri]47[/FONT]
[/TD]
[TD="class: xl68, width: 49, bgcolor: transparent"][FONT=Calibri]etc.[/FONT]
[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]11[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]18[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]38[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]48[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]1[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]2[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]3[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]4[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]5[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 33, bgcolor: transparent"][FONT=Calibri]7[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]20[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]49[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]55[/FONT]
[/TD]
[TD="class: xl68, width: 49, bgcolor: transparent"][FONT=Calibri]etc. [/FONT]
[/TD]
[TD="class: xl68, width: 49, bgcolor: transparent"][FONT=Calibri]etc.[/FONT]
[/TD]
[/TR]
[TR]
[TD="class: xl65, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]2[/COLOR][/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]26[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]44[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]46[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]47[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]7[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]8[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]9[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]10[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]11[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]12[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 49, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]8[/COLOR][/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]14[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]26[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]33[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]51[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]13[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]14[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]15[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]16[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]17[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]18[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 49, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, width: 32, bgcolor: transparent"][FONT=Calibri][COLOR=#3e3e3e]5[/COLOR][/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]6[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]9[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]25[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]39[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]41[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]19[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]20[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]21[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]22[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]23[/FONT]
[/TD]
[TD="class: xl66, width: 41, bgcolor: transparent"][FONT=Calibri]24[/FONT]
[/TD]
[TD="class: xl70, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 33, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 41, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 49, bgcolor: transparent"][/TD]
[TD="class: xl69, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
and for the next number, the same thing, the tabe go down one place and according from the new position swap the numbers.
The position talbe is on H:M from 1 to 500, I don't write H1:M500 because remember this table go down one row every time, and the results in O:T; well at least I don't find another way to explain.
Thanks for reading this.
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Few questions about the middle table

Are these (1 to 30) the actual values in this table?
Is the table size fixed ?
Can you convert this to a single column table?

If you can change to a single column, would be easy to provide a formula solution, is it ok? or you need VBA?
 
Upvote 0
Don't know if I understand the last comment about rows going through 500.
Does this array formula work--enter with Ctrl+Shift+Enter:

=MIN(IF(A1=$A2:$F500,$H2:$M500))
 
Upvote 0
Thanks sanrv1f for reading my post.
the actual values in the table are (1 to 500)
and the table size is fixed.
single column not I can't
If I need a vba Yes please.
 
Upvote 0
Try this

Code:
Sub fnd_prev_pos()
Dim data_rng As Range, rng As Range, cl As Range, cl1 As Range, i As Long, j As Long, cols As Long, rws As Long, first_col As Long, t As Integer, ar As Areas
Set data_rng = Range("A1:F1900")   ' set your range here
rws = data_rng.Rows.Count
cols = data_rng.Columns.Count
first_col = data_rng.Cells(1).Column


For i = 1 To rws
For Each cl In Range("H1:M5")   ' set your middle table range
    With Range("A" & i & "F1900") ' adjust the last cell address to actual
    Debug.Print Range("A" & i & data_rng.Cells(data_rng.Cells.Count)).Address
        If Not .Find(cl, LookAt:=xlWhole) Is Nothing Then
            .Replace cl, ""
            Set rng = .SpecialCells(xlCellTypeBlanks)
            rng.Value = cl
            If rng.Cells(1).Row = i And rng.Cells.Count > 1 Then
                t = 1
                For Each ar In rng.Areas
                    For Each cl1 In ar
                        If t = 2 Then
                            Cells(i, Columns.Count).End(xlToLeft).Offset(, 1) = (cl1.Row - i) * cols + (cl1.Column - first_col + 1)
                        End If
                        t = t + 1
                    Next
                Next
                
            End If
        End If
    End With
Next
Next
End Sub

Assumptions

1. There are no formulas in the first table
2. I have added a new column to mark the beginning of the swap table
Excel Workbook
OPQRST
1x7828
2x720
3x910
4x
5
Sheet1
Excel 2010
 
Upvote 0
Thanks Sanrv1t but give me this : Run-time error' 1004' Method' range' of object _Global failed

Code:
[TABLE="width: 1008"]
<tbody>[TR]
[TD="class: xl63, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]A[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]B[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]C[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]D[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]E[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]F[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]G[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]H[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]I[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]J[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]K[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]L[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]M[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]N[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]O[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]P[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]Q[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]R[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]S[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl64, width: 64, bgcolor: yellow"][FONT=Calibri][SIZE=3][COLOR=#000000]T[/COLOR][/SIZE][/FONT]
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF, align: right"][FONT=Calibri]1[/FONT]
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#3e3e3e]2[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]6[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]25[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]31[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]37[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]50[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]1[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]2[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]3[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]4[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]5[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]6[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]7[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]8[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]28[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]52[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]47[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]etc.[/COLOR][/SIZE][/FONT]
[/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF, align: right"][FONT=Calibri]2[/FONT]
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#3e3e3e]2[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]6[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]11[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]18[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]38[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]48[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]7[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]8[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]9[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]10[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]11[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]12[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF, align: right"][FONT=Calibri]3[/FONT]
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#3e3e3e]2[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]22[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]26[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]44[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]46[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]47[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]13[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]14[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]15[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]16[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]17[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]18[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF, align: right"][FONT=Calibri]4[/FONT]
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#3e3e3e]8[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]14[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]22[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]26[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]33[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]51[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]19[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]20[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]21[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]22[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]23[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]24[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl69, width: 64, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl65, bgcolor: #BFBFBF, align: right"][FONT=Calibri]5[/FONT]
[/TD]
[TD="class: xl66, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#3e3e3e]5[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]6[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]9[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]25[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]39[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]41[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl68, width: 64, bgcolor: transparent"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]25[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]26[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]27[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]28[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]29[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]30[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]31[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]32[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]33[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]34[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]35[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]36[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]37[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]38[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]39[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]40[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]41[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]42[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]43[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]44[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]45[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]46[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]47[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]48[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]49[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]50[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]51[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]52[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]53[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl67, width: 64, bgcolor: transparent"][FONT=Calibri][SIZE=3][COLOR=#574123]54[/COLOR][/SIZE][/FONT]
[/TD]
[TD="class: xl70, bgcolor: gray"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[TD="class: xl63, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]
THE swap table is from H:M
and the result must be at O:T
 
Upvote 0
Where did you place the code? in a standard module? or sheet module?

You need to run the code from the worksheet

You need to fill a column before column O with some data to mark the beginning of the swap table, as shown in the table below the code in my previous post
 
Upvote 0
Fixed few lines

Code:
Sub fnd_prev_pos()
Dim data_rng As Range, rng As Range, cl As Range, cl1 As Range, i As Long, j As Long, cols As Long, rws As Long, first_col As Long, t As Integer, ar As Range
Set data_rng = Range("A1:F5")   ' set your range here
rws = data_rng.Rows.Count
cols = data_rng.Columns.Count
first_col = data_rng.Cells(1).Column


For i = 1 To rws
For Each cl In Range("H1:M5")   ' set your middle table range
    With Range("A" & i, "F5")  ' adjust the last cell address to actual
        If Not .Find(cl, LookAt:=xlWhole) Is Nothing Then
            .Replace cl, ""
            Set rng = .SpecialCells(xlCellTypeBlanks)
            rng.Value = cl
            If rng.Cells(1).Row = i And rng.Cells.Count > 1 Then
                t = 1
                For Each ar In rng.Areas
                    For Each cl1 In ar
                        If t = 2 Then
                            Cells(i, Columns.Count).End(xlToLeft).Offset(, 1) = (cl1.Row - i) * cols + (cl1.Column - first_col + 1)
                        End If
                        t = t + 1
                    Next
                Next
                
            End If
        End If
    End With
Next
Next
End Sub
 
Upvote 0
Hi Sanrv1t.
I when to : -Copy,-Open the Worksheet - Developer, -Visual Basic, -Insert, -Module, -Paste. -Run buttom.

N is before O, I have to write just two or four row as xxx or all the way down?.

Still do not work, not even a mesages, nothing.
 
Upvote 0
Have you adjusted the ranges to match the actual ranges?

Is there any other column with data after column N?

You need to fill column O all the way down, till the end of first table

Try placing the the code in the sheet module
 
Upvote 0

Forum statistics

Threads
1,216,512
Messages
6,131,091
Members
449,618
Latest member
lewismillar

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