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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,224,814
Messages
6,181,127
Members
453,021
Latest member
Justyna P

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