# Counting the max numbers and moving to separate column

• Hi,

I was hoping someone could help me out with writing a VBA code. I currently have the G column that looks like this and I want to develop a code so that it outputs the numbers that are bolded into the H column. Basically the column is a counter that counts until a 0 is found. I want the max number of each counter. I am completely unfamiliar with writing any VBA code and any help would be appreciated. Thanks for looking!

G H
2 2
1 6
0 2
0 3
0 .
6 .
5 .
4
3
2
1
0
2
1
0
3
2
1
0
.
.
.

• Hi,
maybe so

• Hi nilem,

I was hoping it would work but I'm getting an error:
Run-time error '13':
Type mismatch

I'm getting it on this line:
If x(i, 1) > mx Then mx = x(i, 1)

What exactly does this mean?

• This means that not all data are numbers. Please attach a sample file with your data.

• I attached a sample file. I'll try to explain what I'm doing. I'm looking at rain data in Pennsylvania and there are days where it does and doesn't rain. I set up a COUNT that would count days it rained as a 1 and days it didn't as a 0. I then used a MATCH formula that would count successive days for either the days it rained(1) or days it didn't (0). You can see that under the ZEROS column it counts down from a day it didn't rain until it hits a day it does rain with the high number being the highest number of successive days it didn't rain. The same goes for the ONES column where it did rain. That's why I want the MAX number of successive days it does rain for the ZEROS column as well as the ONES column. I appreciate your help thus far.

## Files

• It seems you need subtotal G column. See attached file Sheet 1 for subtotal. Sheet 2 for extracted data.

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!