loop code require

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm trying to write one logic (in loop). How can I write rk value. I want to read rk every cell value.
VBA Code:
Sub code()

Sheets("Sheet1").Select

Dim cn As Integer
Dim i As Integer

i = 2
cn = Range("BN" & Rows.Count).End(xlUp).Row

Dim rk As Integer
rk = Range("BN2") 'comment - read every value..

For i = 2 To cn
If ActiveSheet.Range(Cells(i, "BN")) = rk Then


End If
Next i

End Sub
 
So, I work a full time job and can sometimes chime and help during the day, but not all the time. You posted 4 times after I went to bed last night and as I was coming to work today.

I want to help. Have more patience. I need to ask questions and I need you to respond to the questions. The code you have provided has me asking more questions. I'll get back to you later.

OK?
Hi Jeffrey, just checking any luck on code pls
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Why is row 16 not highlighted in green ?
If you are happy to rely on Column BO, why not just filter on that column for the value 1 and copy the filtered rows ?
 
Upvote 0
Why is row 16 not highlighted in green ?
If you are happy to rely on Column BO, why not just filter on that column for the value 1 and copy the filtered rows ?
row no 16 is not will not picked up / highlighted because, for that rank 1, we've already consider 2 records. For every rank i want to pick 2 records only.
 
Upvote 0
So do we assume that the each rank is grouped together as in your sample image and that you want to copy the only first 2 rows in the same rank that have a "1" in column BO ?
Also are we copying as Values only (no formatting or formulas) ?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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