ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Troble with Code (https://www.excelbanter.com/excel-programming/379500-re-troble-code.html)

Gary''s Student

Troble with Code
 
Make sure that non of your cells contain Text values.
--
Gary's Student


"JOUIOUI" wrote:

I'm using this code to force any currency values in the selected cells to
negative. Most of the time the codes runs great, but other times it doesn't,
I get a "run time error -13 Type Mismatch". It seems to stop running when it
hits cell G92. Any ideas what could be wrong.

Also I copied this code from this site. I understand most of it but what
does the text Abs mean in the code ".Value = -Abs(.Value)"? Thanks for your
assistance and happy holidays.

Sub ForceCellsToNegative()

Dim Rng As Range
Dim rCell As Range

Set Rng =
Range("B105,B109,B61,B62,B64,B65,B67,B68,G7,G8,G20 :G31,G33:G44,G46:G57,G77:G79,G82:G101,G103:G104,G1 07:G108")

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






All times are GMT +1. The time now is 02:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com