Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then else problem
I think I originally posted this in the wrong category and now realize this
has to be a vba macro situaion. AHHH! This means trouble for me. :) Here is what I need: If the any cell in column C has text, then the numeric values in column D must be negatives. They are currently all postive numbers now. There are many fields that do not have any text in column C and those numbers must remain postivie numbers. Any help is greatly, greatly appreciated. -- CLG |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then else problem
I answered your OTHER version of this question. Just modify to put into a
loop Right click sheet tabview codeinsert this. Private Sub Worksheet_Change(ByVal Target As Range) 'On Error Resume Next If Target.Address < Range("c3").Address Then Exit Sub If Not IsNumeric(Target) Then If IsNumeric(Target.Offset(1)) Then Target.Offset(1) = -Abs(Target.Offset(1)) End If End If End Sub ========= For your CURRENT question Sub loopchgvaluetoneg() For Each c In Range("c12:c15") If Not IsNumeric(c) Then If IsNumeric(c.Offset(, 1)) Then c.Offset(, 1) = -Abs(c.Offset(, 1)) End If End If Next c End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Legal Learning" wrote in message ... I think I originally posted this in the wrong category and now realize this has to be a vba macro situaion. AHHH! This means trouble for me. :) Here is what I need: If the any cell in column C has text, then the numeric values in column D must be negatives. They are currently all postive numbers now. There are many fields that do not have any text in column C and those numbers must remain postivie numbers. Any help is greatly, greatly appreciated. -- CLG |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then else problem
Try this:
========== Sub TextEqualNegative() Dim cell As Range, RNG As Range Set RNG = Columns("B:B").SpecialCells(xlCellTypeConstants, 2) For Each cell In RNG Range("C" & cell.Row).Value = -Abs(Range("C" & cell.Row).Value) Next cell End Sub ========== Does that work for you? -- "Actually, I *am* a rocket scientist." -- JB (www.MadRocketScientist.com) Your feedback is appreciated, click YES if this post helped you. "Legal Learning" wrote: I think I originally posted this in the wrong category and now realize this has to be a vba macro situaion. AHHH! This means trouble for me. :) Here is what I need: If the any cell in column C has text, then the numeric values in column D must be negatives. They are currently all postive numbers now. There are many fields that do not have any text in column C and those numbers must remain postivie numbers. Any help is greatly, greatly appreciated. -- CLG |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
If then else problem
If you want to use formulas, put this in column E:
=IF(ISTEXT(C1),-ABS(D1),ABS(D1)) copy it down, then copy the range paste special/values over the equivalent range in D. A macro is better if this isn't a one-off process though. Sam "Legal Learning" wrote: I think I originally posted this in the wrong category and now realize this has to be a vba macro situaion. AHHH! This means trouble for me. :) Here is what I need: If the any cell in column C has text, then the numeric values in column D must be negatives. They are currently all postive numbers now. There are many fields that do not have any text in column C and those numbers must remain postivie numbers. Any help is greatly, greatly appreciated. -- CLG |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |