Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Odds need period, evens need semicolon

A long list of names looks like
Tiger
Cat
Dog
Goose

I want to add a period after Tiger, Dog, and add a semicolon after Cat
and Goose.

What is the feasible approach? Loop will not work, right? How about
array? Can you give me a few lines of codes?

Thanks a lot!

H.Z.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Odds need period, evens need semicolon

Where is this long list of names at? What is the rule that determines which
gets a period and which gets a semi-colon?

Rick


"Curious" wrote in message
...
A long list of names looks like
Tiger
Cat
Dog
Goose

I want to add a period after Tiger, Dog, and add a semicolon after Cat
and Goose.

What is the feasible approach? Loop will not work, right? How about
array? Can you give me a few lines of codes?

Thanks a lot!

H.Z.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Odds need period, evens need semicolon

Maybe...
=a1&if(mod(row(),2)=1,".",";")

In code:

Option Explicit
Sub testme()

Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each myCell In myRng.Cells
If myCell.Row Mod 2 = 0 Then
myCell.Value = myCell.Value & ";"
Else
myCell.Value = myCell.Value & "."
End If
Next myCell
End Sub


Curious wrote:

A long list of names looks like
Tiger
Cat
Dog
Goose

I want to add a period after Tiger, Dog, and add a semicolon after Cat
and Goose.

What is the feasible approach? Loop will not work, right? How about
array? Can you give me a few lines of codes?

Thanks a lot!

H.Z.


--

Dave Peterson
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
Handling Excel Evens in addins Tim Marsden[_2_] Excel Programming 5 October 26th 06 06:32 AM
Period to Period percentage change? cs120 Excel Discussion (Misc queries) 1 September 18th 05 12:05 PM
Sorting Odds & Evens Tom Ogilvy Excel Programming 0 July 13th 03 09:30 PM
Sorting Odds & Evens Bob Phillips[_5_] Excel Programming 1 July 13th 03 08:37 PM
Sorting Odds & Evens JMay Excel Programming 0 July 13th 03 02:50 PM


All times are GMT +1. The time now is 12:19 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"