Rollnation
New Member
- Joined
- Jan 17, 2017
- Messages
- 17
Hello all, I am trying to figure out the VBA to replace all negative values in a specific range, on a specific worksheet "MonteCarlo", Range "S3:AMD163". I have tried unsuccessfully couple of times with the following code:
Amy help from a more seasoned VBA writer would be appreciated!
Sub Replace_Negatives()
'Dim ws As Worksheet
'Dim rng As Range
'Application.ScreenUpdating = False
'Set ws = ThisWorkbook.Sheets("MonteCarlo")
'Set rng = ws.Range("S3:AMD163")
'For Each rng In rng.Cells
'If cell.Value < 0 Then cell.Value = 0
'Application.ScreenUpdating = True
'End Sub
Sub Second_Try()
'Dim RowNum As Long, ColNum As Long
'Application.ScreenUpdating = False
'For ColNum = 19 To Cells(1, Columns.Count).End(xlToLeft).Column
'For RowNum = 3 To Cells(Rows.Count, ColNum).End(xlUp).Row
' If Val(Cells(RowNum, ColNum)) And Cells(RowNum, ColNum) < 0 Then Cells(RowNum, ColNum) = 0
'Next RowNum
'Next ColNum
'Application.ScreenUpdating = True
'End Sub
Amy help from a more seasoned VBA writer would be appreciated!
Sub Replace_Negatives()
'Dim ws As Worksheet
'Dim rng As Range
'Application.ScreenUpdating = False
'Set ws = ThisWorkbook.Sheets("MonteCarlo")
'Set rng = ws.Range("S3:AMD163")
'For Each rng In rng.Cells
'If cell.Value < 0 Then cell.Value = 0
'Application.ScreenUpdating = True
'End Sub
Sub Second_Try()
'Dim RowNum As Long, ColNum As Long
'Application.ScreenUpdating = False
'For ColNum = 19 To Cells(1, Columns.Count).End(xlToLeft).Column
'For RowNum = 3 To Cells(Rows.Count, ColNum).End(xlUp).Row
' If Val(Cells(RowNum, ColNum)) And Cells(RowNum, ColNum) < 0 Then Cells(RowNum, ColNum) = 0
'Next RowNum
'Next ColNum
'Application.ScreenUpdating = True
'End Sub