Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheetfunction Substitute

Sub PurchaseReport()

Dim JDEdata, x as Long

'Correct JDE Credit Format


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

If Right(JDEdata, 1) = "-" Then
Range("G" & x) = "-" & Left(JDEdata,len(JDEData)-1)
End If
Next x
End sub

If you wanted to use the worksheet function substitute instead of the VBA
function Left and Len, you would do
Range("G" & x) = "-" & Application.WorksheetFunction.Substitute(JDEdata,
"-", , 1)

You could also use

Range("G" & x) = cdbl(JDEdata)

--
Regards,
Tom Ogilvy

"Helen" wrote:

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

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
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE.... max. limit 8 :( [email protected] Excel Discussion (Misc queries) 6 May 22nd 08 05:33 PM
Worksheetfunction Substitute Bob Phillips Excel Programming 0 December 20th 06 01:24 PM
Can't use WorksheetFunction Yossi Excel Discussion (Misc queries) 5 January 25th 06 10:07 PM
WorkSheetFunction.CountIf & WorkSheetFunction.SumIf with 2 conditions? Etien[_2_] Excel Programming 3 January 13th 04 04:07 PM
WorksheetFunction Mike Fogleman Excel Programming 2 January 1st 04 11:17 PM


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