#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default IF , Then

Hello from Steved
In vba I would like to do the below please
In Column A:A
City to be 1-City
Roskill to be 2-Rosk
Papakura to be 3-Papa
Wiri to be 4-Wiri
Shore to be 5-Shore
Orewa to be 6-Orewa
Swanson to be 7-Swan
Panmure to be 8-Panm
Waiheke to be 9-Waih
An example would be City will Become 1-City
Thankyou,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF , Then

For x = 1 To 9
Cells(x, 1).Value = x & "-" & Cells(x, 1).Value
Next x

Does that work for you? - Piku

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IF , Then

In another column

=Row()&"-"&A1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Steve" wrote in message
...
Hello from Steved
In vba I would like to do the below please
In Column A:A
City to be 1-City
Roskill to be 2-Rosk
Papakura to be 3-Papa
Wiri to be 4-Wiri
Shore to be 5-Shore
Orewa to be 6-Orewa
Swanson to be 7-Swan
Panmure to be 8-Panm
Waiheke to be 9-Waih
An example would be City will Become 1-City
Thankyou,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default IF , Then

Hello Pikus from Steved

Pikus please bare with me as I am a novice, thanks

Please if I type City anywhere in Column A:A
would the below vba return 1-City, if yes below is my
attempt

For City = 1
Cells(City, 1).Value = City & "1-City" & Cells(City,
1).Value
Next City

Thankyou.

-----Original Message-----
For x = 1 To 9
Cells(x, 1).Value = x & "-" & Cells(x, 1).Value
Next x

Does that work for you? - Pikus


---
Message posted from http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF , Then

I understand. Here is what the code I posted does if it is completel
unaltered. The line that says, “For x = 1 To 9” is used here to ru
through rows 1 – 9. It runs the code between that and “Next x” onc
for each row. The variable named “x” stands for the number of the ro
that is currently being worked with. It takes the information in th
first cell of the row, no matter what it says, and adds the number o
the row and a dash to the front of the value of the cell.
SO, if cell A1 says “city”, it gets changed to “1-city”
If it contains the word “airplane” it changes into “1-airplane”
Cell A2 goes from “candy” to “2-candy” and so on.

I was uncertain that I fully understood what you intended to accomplis
with this, so if this is not the affect you wanted, please let me know
Also, I want to stress that the code I posted should be use
unaltered. You should cut and paste it to wherever you want it an
change nothing. I would like to explain the code in a bit more detail
but I am on my way out the door. I'm sure someone else would be happ
to take care of that for you if you request it. - Piku

--
Message posted from http://www.ExcelForum.com

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



All times are GMT +1. The time now is 04:27 AM.

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

About Us

"It's about Microsoft Excel"