VBA Code

ds_robb

Board Regular
Joined
Aug 25, 2002
Messages
72
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
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
 

zacemmel

Well-known Member
Joined
Apr 29, 2002
Messages
636
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
 

ds_robb

Board Regular
Joined
Aug 25, 2002
Messages
72
Thanks, used a combination of both of these answers and it is working perfectly.
Regards
Duncan
 

Forum statistics

Threads
1,144,307
Messages
5,723,629
Members
422,505
Latest member
Noar33

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
Top