Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help w/ VBA code

Hi;

I'm new to VBA and need to get A LOT done quickly. I need help with some
simple code for the following:

I have a sheet with a column (~1500 rows) in which each cell contians a
numeric value. I want to create a new column in which cell contains a text
string based on the numeric value in the first column; i.e.:

If A1 < 0, then B1="string1"
If A1 =0, then B1="string2"

and so on for all cells in column.

Any help, suggestions?

Thanks in advance,
-jbb


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Help w/ VBA code

Hi

personally i wouldn't worry about using VBA for this - i would type an IF
formula
=IF(A1<0,"string1","string2")
in cell B1 and then double click the autofill handle (bottom right hand
corner of the cell) - then i would select column B and copy - edit / paste
special values

however, if you do want code

Sub addstrings()
For Each c In Range("A1:A1500") 'set range to suit
If c.Value < 0 Then
c.Offset(0, 1).Value = "string1"
Else
c.Offset(0, 1).Value = "string2"
End If
Next
End Sub

--- note, this code assumes that column B is blank and can be used for entry
of the strings. It also assumes that each cell in column A has a number
either less than zero, zero or greater than zero.

Hope this helps
Cheers
JulieD


"J.B. Bobbitt" wrote in message
k.net...
Hi;

I'm new to VBA and need to get A LOT done quickly. I need help with some
simple code for the following:

I have a sheet with a column (~1500 rows) in which each cell contians a
numeric value. I want to create a new column in which cell contains a
text string based on the numeric value in the first column; i.e.:

If A1 < 0, then B1="string1"
If A1 =0, then B1="string2"

and so on for all cells in column.

Any help, suggestions?

Thanks in advance,
-jbb



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help w/ VBA code

Thanks and a hat tip, Julie. I'm off and running.

-jbb

"JulieD" wrote in message
...
Hi

personally i wouldn't worry about using VBA for this - i would type an IF
formula
=IF(A1<0,"string1","string2")
in cell B1 and then double click the autofill handle (bottom right hand
corner of the cell) - then i would select column B and copy - edit / paste
special values

however, if you do want code

Sub addstrings()
For Each c In Range("A1:A1500") 'set range to suit
If c.Value < 0 Then
c.Offset(0, 1).Value = "string1"
Else
c.Offset(0, 1).Value = "string2"
End If
Next
End Sub

--- note, this code assumes that column B is blank and can be used for
entry of the strings. It also assumes that each cell in column A has a
number either less than zero, zero or greater than zero.

Hope this helps
Cheers
JulieD


"J.B. Bobbitt" wrote in message
k.net...
Hi;

I'm new to VBA and need to get A LOT done quickly. I need help with some
simple code for the following:

I have a sheet with a column (~1500 rows) in which each cell contians a
numeric value. I want to create a new column in which cell contains a
text string based on the numeric value in the first column; i.e.:

If A1 < 0, then B1="string1"
If A1 =0, then B1="string2"

and so on for all cells in column.

Any help, suggestions?

Thanks in advance,
-jbb





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Help w/ VBA code

you're welcome ... do come back if you get stuck again.

"J.B. Bobbitt" wrote in message
nk.net...
Thanks and a hat tip, Julie. I'm off and running.

-jbb

"JulieD" wrote in message
...
Hi

personally i wouldn't worry about using VBA for this - i would type an IF
formula
=IF(A1<0,"string1","string2")
in cell B1 and then double click the autofill handle (bottom right hand
corner of the cell) - then i would select column B and copy - edit /
paste special values

however, if you do want code

Sub addstrings()
For Each c In Range("A1:A1500") 'set range to suit
If c.Value < 0 Then
c.Offset(0, 1).Value = "string1"
Else
c.Offset(0, 1).Value = "string2"
End If
Next
End Sub

--- note, this code assumes that column B is blank and can be used for
entry of the strings. It also assumes that each cell in column A has a
number either less than zero, zero or greater than zero.

Hope this helps
Cheers
JulieD


"J.B. Bobbitt" wrote in message
k.net...
Hi;

I'm new to VBA and need to get A LOT done quickly. I need help with
some simple code for the following:

I have a sheet with a column (~1500 rows) in which each cell contians a
numeric value. I want to create a new column in which cell contains a
text string based on the numeric value in the first column; i.e.:

If A1 < 0, then B1="string1"
If A1 =0, then B1="string2"

and so on for all cells in column.

Any help, suggestions?

Thanks in advance,
-jbb







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Help w/ VBA code

Oh, I will............. (and have).

-jbb


"JulieD" wrote in message
...
you're welcome ... do come back if you get stuck again.

"J.B. Bobbitt" wrote in message
nk.net...
Thanks and a hat tip, Julie. I'm off and running.

-jbb

"JulieD" wrote in message
...
Hi

personally i wouldn't worry about using VBA for this - i would type an
IF formula
=IF(A1<0,"string1","string2")
in cell B1 and then double click the autofill handle (bottom right hand
corner of the cell) - then i would select column B and copy - edit /
paste special values

however, if you do want code

Sub addstrings()
For Each c In Range("A1:A1500") 'set range to suit
If c.Value < 0 Then
c.Offset(0, 1).Value = "string1"
Else
c.Offset(0, 1).Value = "string2"
End If
Next
End Sub

--- note, this code assumes that column B is blank and can be used for
entry of the strings. It also assumes that each cell in column A has a
number either less than zero, zero or greater than zero.

Hope this helps
Cheers
JulieD


"J.B. Bobbitt" wrote in message
k.net...
Hi;

I'm new to VBA and need to get A LOT done quickly. I need help with
some simple code for the following:

I have a sheet with a column (~1500 rows) in which each cell contians a
numeric value. I want to create a new column in which cell contains a
text string based on the numeric value in the first column; i.e.:

If A1 < 0, then B1="string1"
If A1 =0, then B1="string2"

and so on for all cells in column.

Any help, suggestions?

Thanks in advance,
-jbb









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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
option buttons run Click code when value is changed via VBA code neonangel Excel Programming 5 July 27th 04 08:32 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


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