Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default VBA - Finding the odd one out

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA - Finding the odd one out

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)

"NateBuckley" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default VBA - Finding the odd one out

I forgot to mention you need to use the MOD function not the %

a = 10 Mod 2

"NateBuckley" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default VBA - Finding the odd one out

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

"NateBuckley" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default VBA - Finding the odd one out

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!

"Joel" wrote:

I forgot to mention you need to use the MOD function not the %

a = 10 Mod 2

"NateBuckley" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default VBA - Finding the odd one out

Hi Mike,

Using option explicit,

How would you define the variables?

Lastrow
c

Dan
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default VBA - Finding the odd one out

Long

"dan dungan" wrote:

Hi Mike,

Using option explicit,

How would you define the variables?

Lastrow
c

Dan

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default VBA - Finding the odd one out

Sorry Dan

Lastrow as Long
C as Range

"dan dungan" wrote:

Hi Mike,

Using option explicit,

How would you define the variables?

Lastrow
c

Dan

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default VBA - Finding the odd one out

Thanks, Mike.

I'm still trying to figure out how to dimension the correct data type.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding max value millwalll Excel Programming 4 January 3rd 08 11:02 PM
Finding Same Row Value JN[_6_] Excel Programming 4 May 26th 06 04:43 PM
Finding Row fak119 Excel Discussion (Misc queries) 3 May 18th 06 05:54 PM
finding value ceemo Excel Discussion (Misc queries) 4 April 20th 06 02:16 PM
Finding a sum Realwoodies Excel Programming 3 February 25th 04 11:46 PM


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"