Vba macro to list un colored data remaining but instead of the number that is uncolored it would list the position it is on.

Estatefinds

Board Regular
Joined
Sep 14, 2015
Messages
169
So for the following data: The individual numbers are in columns BB Through BF.
so I need a macro to list the remaining uncolored numbers data but instead of the number itself listed it would be the position in which it sits. so the first example will show the numbers and the second example will show the positions. and place the list in column AN on the same row its starts reading data at from top to bottom. Please! Thank you
38131426
38132728
124272830
510122433
414151731
211181922
717182628
515193234
69162634
914223033
1018243135
418192731
24202433
2025272932
417252630
1315182035
37132633
1021242834
1218252834
315252729
2892131
1012173033
28131732
38182533
2483334
25162123
45222324
322252633
711161928
213183133
36101823
813162133
912232735
623252730
46272832
1220222730
917212235
1381632
3492728
1516242527
522263032
47101620
310162032
410252735
617192829
611121625
1392528
611162225
17141722
1522243132
35172329
1516232528
1892124
1421223233
714172529
614223033
1020232833
69101627
19202730
12101820
819232933
918192933
1518192226
618202735
813232834
515233435
613242829
17273035
1571831
912161835

<tbody>
</tbody>


second example:
A1B1C1D1E1
A2B2C2D2E2
A3B3C3D3E3
A4B4C4D4E4
A5B5C5D5E5
A6B6C6D6E6
A7B7C7D7E7
A8B8C8D8E8
A9B9C9D9E9
A10B10C10D10E10
A11B11C11D11E11
A12B12C12D12E12
A13B13C13D13E13
A14B14C14D14E14
A15B15C15D15E15
A16B16C16D16E16
A17B17C17D17E17
A18B18C18D18E18
A19B19C19D19E19
A20B20C20D20E20
A21B21C21D21E21
A22B22C22D22E22
A23B23C23D23E23
A24B24C24D24E24
A25B25C25D25E25
A26B26C26D26E26
A27B27C27D27E27
A28B28C28D28E28
A29B29C29D29E29
A30B30C30D30E30
A31B31C31D31E31
A32B32C32D32E32
A33B33C33D33E33
A34B34C34D34E34
A35B35C35D35E35
A36B36C36D36E36
A37B37C37D37E37
A38B38C38D38E38
A39B39C39D39E39
A40B40C40D40E40
A41B41C41D41E41
A42B42C42D42E42
A43B43C43D43E43
A44B44C44D44E44
A45B45C45D45E45
A46B46C46D46E46
A47B47C47D47E47
A48B48C48D48E48
A49B49C49D49E49
A50B50C50D50E50
A51B51C51D51E51
A52B52C52D52E52
A53B53C53D53E53
A54B54C54D54E54
A55B55C55D55E55
A56B56C56D56E56
A57B57C57D57E57
A58B58C58D58E58
A59B59C59D59E59
A60B60C60D60E60
A61B61C61D61E61
A62B62C62D62E62
A63B63C63D63E63
A64B64C64D64E64
A65B65C65D65E65
A66B66C66D66E66
A67B67C67D67E67
A68B68C68D68E68
A69B69C69D69E69
A70B70C70D70E70

<tbody>
</tbody>
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
The number 7 is bolded as well i missed that one when i was bold typing them, on the first example first column below the 6th number.
 
Upvote 0
Like this?

Code:
Sub ListCells()
Dim FirstRow As Long, ResultRow As Long, r As Long, c As Long

    FirstRow = -1
    For r = 1 To 1000
        If Cells(r, "BB") <> "" Then
            If FirstRow = -1 Then
                FirstRow = r - 1
                ResultRow = r
            End If
            For c = 54 To 58
                If Cells(r, c).Interior.ColorIndex = xlNone Then
                    Cells(ResultRow, "AN") = Chr(c + 11) & r - FirstRow
                    ResultRow = ResultRow + 1
                End If
            Next c
        End If
    Next r
        
End Sub
 
Upvote 0
it Worked Great!!! ill be in touch soon when i can work out hese other request.
Thank you Very much!!
Sincerely,
Dennis
 
Upvote 0
I have a code that needs to be adjusted meaning when I select the data in A:E it the macro will read the data in J:N and out put the the position in which the numbers I selected are found below. so there are gaps in the data because i believe it not looking far enough down to find the number which will then return the position. need help please!
ABCDE2/8/2016JKLMN2/8/16STUVW
2/7/20162/7/16
16182629322/6/201616-18-26-29-3216182629322/6/16C9C6E1D14D8
381314262/5/20163-8-13-14-26381314262/5/16A16B1C1B4D6
381327282/4/20163-8-13-27-28381327282/4/16A15B19A14C1D1
1242728302/3/20161-24-27-28-301242728302/3/16A35D1D9E4D7
5101224332/2/20165-10-12-24-335101224332/2/16A4A7A15C7E6
4141517312/1/20164-14-15-17-314141517312/1/16A7B5B3B2D6
2111819221/31/20162-11-18-19-222111819221/31/16A7B23C1C2C4
7171826281/30/20167-17-18-26-287171826281/30/16B10B8B4D2D11
5151932341/29/20165-15-19-32-345151932341/29/16B18B8C4E6E1
691626341/28/20166-9-16-26-34691626341/28/16B22C12C17D6E9
9142230331/27/20169-14-22-30-339142230331/27/16C11C17E5E3
10182431351/26/201610-18-24-31-3510182431351/26/16A7B1D2E1E5
4181927311/25/20164-18-19-27-314181927311/25/16B1C4D17C2E9
242024331/24/20162-4-20-24-33242024331/24/16A8A2D3C5E4
20252729321/23/201620-25-27-29-3220252729321/23/16D2C1D6E6E9
4172526301/22/20164-17-25-26-304172526301/22/16B10C7C4D2D7
13151820351/21/201613-15-18-20-3513151820351/21/16C1B4B3B20E17
371326331/20/20163-7-13-26-33371326331/20/16A3A12C6D11E5
10212428341/19/201610-21-24-28-3410212428341/19/16A4D3E9D1E1
12182528341/18/201612-18-25-28-3412182528341/18/16B3C5C1E10E6
3152527291/17/20163-15-25-27-293152527291/17/16A4A20D4D13E25
28921311/16/20162-8-9-21-3128921311/16/16A2B2A12D5D9
10121730331/15/201610-12-17-30-3310121730331/15/16C9B11D1E12E2
281317321/14/20162-8-13-17-32281317321/14/16A2B1B7B14E12
381825331/13/20163-8-18-25-33381825331/13/16A4C1C6C4D1
24833341/12/20162-4-8-33-3424833341/12/16A5A2A7E3
251621231/11/20162-5-16-21-23251621231/11/16A4B1C3D6D1
452223241/10/20164-5-22-23-24452223241/10/16A8A14B1E4C13
3222526331/9/20163-22-25-26-333222526331/9/16A3C8C6C13E2
7111619281/8/20167-11-16-19-287111619281/8/16B13B17C3C16D6
2131831331/7/20162-13-18-31-332131831331/7/16B30B2D1D20E2
361018231/6/20163-6-10-18-23361018231/6/16B7A3C11D29C2
8131621331/5/20168-13-16-21-338131621331/5/16C6B33D6C5E22
9122327351/4/20169-12-23-27-359122327351/4/16A4A3B1D1E4

<colgroup><col><col span="5"><col><col><col><col span="5"><col><col><col><col span="6"></colgroup><tbody>
</tbody>
Sub count_STUVW_Step35()
Application.ScreenUpdating = False
firstRow = Cells(1, "S").End(xlDown).Row
lastRow = Cells(Rows.Count, "S").End(xlUp).Row
ro = firstRow

' all data
While Not (Cells(ro, "AO") = "")
For c = 19 To 23 'for each column S to W
colA = 42 + (c - 19) * 6
Set searchRange = Range(Cells(ro, c), Cells(ro + 34, c))
Set outputRange = Range(Cells(ro, colA), Cells(ro + 34, colA + 4))
outputRange.clear
outputRange.NumberFormat = "0"
outputRange.BorderAround Weight:=xlThin
For Each cel In outputRange
searchString = Cells(firstRow - 1, cel.Column) & Cells(cel.Row, "AO")
countt = Application.WorksheetFunction.CountIf(searchRange, searchString)
If countt > 0 Then
cel.Value = countt
End If
Next cel
Next
ro = ro + 35
Wend
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Let me know if you get a chance to read last message and of you need me to post as a new post. Thank you!
sincerely, Dennis
 
Last edited:
Upvote 0
Frankly, that code doesn't make a lot of sense. You say it's supposed to read columns A-E, but those are never referenced in the code. I tried stepping through it, and failed because it does reference Column AO, which you did not include on your screen shot. The macro name "Count_STUVW" does not match your description of what it's supposed to do. Further, it has the "magic numbers" of 34 and 35 hard-coded in it. I suspect that those are references to lastRow, which in this example calculates to 35. If you change 34 to (lastRow - 1) and 35 to lastRow in your code, maybe it will solve your problem. But then the line "ro = ro + 35" (or "ro = ro + lastRow") will guarantee that the main loop will only be executed once.

Try making that change and see if it helps. If it doesn't, I'd suggest opening a new thread. Put a before screenshot with all the columns, an after screenshot (manually manipulated to show your expected results), and an explanation of what you're looking for. I don't think posting your code will help, most of the VBA gurus here can probably come up with something cleaner.

Good luck!
 
Upvote 0
ok no problem thanks for looking at it! so what this does is i select say the data A:E on row 84 the same data that is exactly the same is in columns J:N. so when i select the data on row 84 in A:E the position of the numbers are resulted to the right in columns S:W. then i go up the the next row and select the data in columns A:E on row 85 and the resulted positions of these numbers are resulted in S:W. Let me know if this helps? this is all the codes for this worksheet I think these are all connected to work together
Thank You.
Sub count_STUVW_Step35()
Application.ScreenUpdating = False
firstRow = Cells(1, "S").End(xlDown).Row
lastRow = Cells(Rows.Count, "S").End(xlUp).Row
ro = firstRow

' all data
While Not (Cells(ro, "AO") = "")
For c = 19 To 23 'for each column S to W
colA = 42 + (c - 19) * 6
Set searchRange = Range(Cells(ro, c), Cells(ro + 34, c))
Set outputRange = Range(Cells(ro, colA), Cells(ro + 34, colA + 4))
outputRange.clear
outputRange.NumberFormat = "0"
outputRange.BorderAround Weight:=xlThin
For Each cel In outputRange
searchString = Cells(firstRow - 1, cel.Column) & Cells(cel.Row, "AO")
countt = Application.WorksheetFunction.CountIf(searchRange, searchString)
If countt > 0 Then
cel.Value = countt
End If
Next cel
Next
ro = ro + 35
Wend
Application.ScreenUpdating = True
End Sub


Sub clear()
S = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
For Each r In Selection
v = r.Value
For i = 0 To 9
v = Replace(v, S(i), "")
Next
r.Value = v
Next


Sub count_STUVW()
For r = 0 To Selection.Rows.Count - 1
For c = 0 To 4
Cells(Selection.Row + r, 28 + 2 * c) = WorksheetFunction.CountIf(Selection, Cells(Selection.Row + r, 27 + 2 * c))
Next
Next
End Sub





End Sub
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

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