VBA - Finding the odd one out

N

NateBuckley

I have a list of data that follows like so:

A01
A02
A03
A04
A05
A06
A07
A08

I wish to Display only the Odd ones, so A01, A03, A05, A07 and so on, I know
the formula to do this but have no idea how to do it in VBA with code.

I'm guessing it's something to do with the % operator?

Thanks for any help
 
J

Joel

I don't know hwat you mean by display. To get the odd numbers should be
exactly like in the worksheet. use the RIGHT function

=Right(A1,1)
 
M

Mike H

Nate,

Your question isn't clear so I've asssumed you want to filter to show odd rows

Sub sonic()
Dim myrange, copyrange As Range
Lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A1:A" & Lastrow)
For Each c In myrange
If Mid(c.Value, 2, Len(c.Value)) Mod 2 = 0 Then
c.EntireRow.Hidden = True
End If
Next
End Sub

Mike
 
N

NateBuckley

Thanks Joel, I'll give it a whirl now.

I wanted to leave out what I wanted to do with the data afterwards, because
I didn't want anyone going to the trouble of then writing all that code for
me, as what you've just told me is precisly what I needed.

Cheers!
 
D

dan dungan

Hi Mike,

Using option explicit,

How would you define the variables?

Lastrow
c

Dan
 
D

dan dungan

Thanks, Mike.

I'm still trying to figure out how to dimension the correct data type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top