Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Trouble with this code

I'm using this macro to force the cells to a negative value. The only thing
is I only need it to force a negative value if there is data in the cell.
This code is filling the empty cells with a value of $ 0.00. I need those
cells to remain empty but just not sure how to alter the code to do that.
Any help you can give is very much appreciated. Thank you


Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B85:B86,G20:G31,G33:G44,G46:G57,G82,G85:G86 ,B91,G7:G8,G77:G79,G83,G89:G90")

For Each rCell In Rng.Cells
With rCell
..Value = -Abs(.Value)
..Font.Name = "Arial"
..Font.Bold = True
..NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"

If Not Rng Is Nothing Then

Else
Exit Sub
End If

End With
Next rCell

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Trouble with this code



--
---
Regards,
Norman



"JOUIOUI" wrote in message
...
I'm using this macro to force the cells to a negative value. The only
thing
is I only need it to force a negative value if there is data in the cell.
This code is filling the empty cells with a value of $ 0.00. I need those
cells to remain empty but just not sure how to alter the code to do that.
Any help you can give is very much appreciated. Thank you


Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B85:B86,G20:G31,G33:G44,G46:G57,G82,G85:G86 ,B91,G7:G8,G77:G79,G83,G89:G90")

For Each rCell In Rng.Cells
With rCell
.Value = -Abs(.Value)
.Font.Name = "Arial"
.Font.Bold = True
.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"

If Not Rng Is Nothing Then

Else
Exit Sub
End If

End With
Next rCell

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Trouble with this code

Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B85:B86,G20:G31,G33:G44,G46:G57,G82,G85:G86 ,B91,G7:G8,G77:G79,G83,G89:G90")

For Each rCell In Rng.Cells
With rCell
if .Value < "" then
..Value = -Abs(.Value)
..Font.Name = "Arial"
..Font.Bold = True
..NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
end if
If Not Rng Is Nothing Then

Else
Exit Sub
End If

End With
Next rCell

End Sub

--
HTH...

Jim Thomlinson


"JOUIOUI" wrote:

I'm using this macro to force the cells to a negative value. The only thing
is I only need it to force a negative value if there is data in the cell.
This code is filling the empty cells with a value of $ 0.00. I need those
cells to remain empty but just not sure how to alter the code to do that.
Any help you can give is very much appreciated. Thank you


Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B85:B86,G20:G31,G33:G44,G46:G57,G82,G85:G86 ,B91,G7:G8,G77:G79,G83,G89:G90")

For Each rCell In Rng.Cells
With rCell
.Value = -Abs(.Value)
.Font.Name = "Arial"
.Font.Bold = True
.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"

If Not Rng Is Nothing Then

Else
Exit Sub
End If

End With
Next rCell

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Trouble with this code

Hi Jouioui,

Why are you opening a new thread?

Perhaps try:
'=============
Public Sub ForceCellsToNegative()
Dim Rng As Range
Dim rCell As Range

Set Rng = Range("B85:B86,G20:G31,G33:G44,G46:G57," _
& "G82 , G85: G86 , B91, G7: G8 ," _
& "G77: G79 , G83, G89: G90 ")

For Each rCell In Rng.Cells
With rCell
If Not IsEmpty(.Value) Then
.Value = -Abs(.Value)
End If

.Font.Name = "Arial"
.Font.Bold = True
.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
End With
Next rCell

End Sub
'<<=============


---
Regards,
Norman


"JOUIOUI" wrote in message
...
I'm using this macro to force the cells to a negative value. The only
thing
is I only need it to force a negative value if there is data in the cell.
This code is filling the empty cells with a value of $ 0.00. I need those
cells to remain empty but just not sure how to alter the code to do that.
Any help you can give is very much appreciated. Thank you


Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B85:B86,G20:G31,G33:G44,G46:G57,G82,G85:G86 ,B91,G7:G8,G77:G79,G83,G89:G90")

For Each rCell In Rng.Cells
With rCell
.Value = -Abs(.Value)
.Font.Name = "Arial"
.Font.Bold = True
.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"

If Not Rng Is Nothing Then

Else
Exit Sub
End If

End With
Next rCell

End Sub



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
trouble with code to move text JOUIOUI Excel Programming 1 July 21st 06 01:16 PM
Trouble with Code to change sheet name JOUIOUI Excel Programming 3 July 6th 06 04:15 PM
Trouble with this code JOUIOUI Excel Programming 4 June 11th 06 04:49 PM
Trouble Condensing Code Ikaabod Excel Programming 3 April 11th 06 09:53 PM
Print dialog code trouble Tim[_36_] Excel Programming 1 April 18th 04 08:46 AM


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