Capture every number in the range and populate the field

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Using Excel 2010
Hello,

I need VBA which find the every numbers is in the range (from the 1 to 35 numbers). Check it within the rows 5 into 5.

Here is an example…

1st starting ranges C6:G10, (list every number from 1 to 35 numbers) in the Cell J10 to right under the header number in the range J10:AR10

2nd starting ranges C7:G11, (list every number from 1 to 35 numbers) in the Cell J11 to right under the header number in the range J11:AR11

3rd starting ranges C8:G12, (list every number from 1 to 35 numbers) in the Cell J12 to right under the header number in the range J12:AR12

And so on till end of the data……

Example sheet attached

Find Unique.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQAR
1
2
3
4
5n1n2n3n4n51234567891011121314151617181920212223242526272829303132333435
627282213
72420112312
8111828129
9969178
102211247261st Capture Every Number In The Range C6:G10-->126789111213171820222324262829
112021912202nd Capture Every Number In The Range C7:G11-->16789111217182021222324262829
123016251443rd Capture Every Number In The Range C8:G12-->149789111214161718202122242526282930
1341719309?
14225162518?
152123212535?
16212141220?
17722232918?
18171342221?
194917225?
2029132635?
21917736
22
23
List Every Number In Range


Regards,
Moti
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hello, if you are not insisting on VBA you could try:

Excel Formula:
=IF(COUNTIF($C6:$G10,J$5)>0,J$5,"")
 
Upvote 1
Try.
VBA Code:
Sub CaptureNumbers()
Dim Rng As Range
Dim Lr&, T&, rng1$
Dim M

Lr = Range("C" & Rows.Count).End(xlUp).Row
Set Rng = Range("C6:G10")
For T = 10 To Lr
rng1 = Rng.Offset(T - 10, 0).Address
M = Evaluate("Transpose(if(countif(" & rng1 & ",Row(1:35))>0,Row(1:35),""""))")
Range("J" & T).Resize(1, 35) = M: M = ""
Next T

End Sub
 
Upvote 1
Solution
Try.
VBA Code:
Sub CaptureNumbers()
Dim Rng As Range
Dim Lr&, T&, rng1$
Dim M

Lr = Range("C" & Rows.Count).End(xlUp).Row
Set Rng = Range("C6:G10")
For T = 10 To Lr
rng1 = Rng.Offset(T - 10, 0).Address
M = Evaluate("Transpose(if(countif(" & rng1 & ",Row(1:35))>0,Row(1:35),""""))")
Range("J" & T).Resize(1, 35) = M: M = ""
Next T

End Sub
kvsrinivasamurthy, I appreciate you help, thank you for the VBA, it worked Perfect (y)

Wishing you a great weekend! And Good Luck.

Kind regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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