Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default 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
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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


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