ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheetfunction Substitute (https://www.excelbanter.com/excel-programming/379784-re-worksheetfunction-substitute.html)

Bob Phillips

Worksheetfunction Substitute
 
Sub PurchaseReport()

Dim JDEdata

'Correct JDE Credit Format

Range("G4").Select

For x = 4 To myRows
JDEdata = Range("G" & x)

If Right(JDEdata, 1) = "-" Then

JEData = "-" & Left(JEData, Len(JEData) - 1)

End If
Next x
End Sub

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Helen" wrote in message
...
This macro is supposed to reformat numbers that have a "-" sign in them.
Placing the "-" at the front instead of the end of the number.

I'm getting an error message asking me to define the sub / function, what
have I done wrong?

Sub PurchaseReport()

Dim JDEdata

'Correct JDE Credit Format

Range("G4").Select

For x = 4 To myRows
JDEdata = Range("G" & x)

If Right(JDEdata, 1) = "-" Then

Application.WorksheetFunction = Substitute(JDEdata, "-", , 1)

Application.WorksheetFunction = Substitute(JDEdata, Left(JDEdata), "-"
&
Left(JDEdata), 1)

End If
Next x





All times are GMT +1. The time now is 12:36 AM.

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