Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Code to conditional format all black after date specified in code? | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
option buttons run Click code when value is changed via VBA code | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |