VBA Code

ds_robb

Board Regular
Joined
Aug 25, 2002
Messages
73
Can anyone suggest a useful bit of code that will cross a spreadsheet, starting in cell C5 checking what is in that cell and the one directly below (C6) then skip a cell, move on to E5 and do exactly the same all the way over to the far end of the spreadsheet.

For example

C5 = Tough E5 = Tough G5= Tough
C6 = Nut E6 = Luck G6 = Nut

Bacsically I'm looking via VBA to count the number of occurrances within the spreadsheet of Tough and Nut which in the example above there would be two.

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Something like

For iCol = 3 to 9 Step 2 'change 3 and 9 as appropriate
For iRow = 5 to 6
'your code here
Next iRow
Next iCol
 
Upvote 0
i=5
Do while i < 256
if cells(5,i).value & cells(6,i).value = "ToughNut" then
number=1 + number
end if
i=i+i
loop
 
Upvote 0
Thanks, used a combination of both of these answers and it is working perfectly.
Regards
Duncan
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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