Wait what
New Member
- Joined
- Sep 21, 2023
- Messages
- 2
- Office Version
- 2013
- 2011
- 2010
- Platform
- Windows
- Mobile
Hi, I am still getting starting this excel coding, and thought that I kind of had it down pat, but my macro is not doing anything
Any help/tips would be greatly appreciated!!
I have data in cells B2:AB324 and would like the macro to scan/loop through all cells in range, to identify and clear the cell contents
for any cells containing the value of -9.
I have more than one sheet in this workbook, hence the specification; and so far, have come up with this (completely ineffective) code:
Sub ClearNeg9s()
'Clears all cells in range containing '-9'
'Turn off screen updating, for User aesthetics
Application.ScreenUpdating = False
'Only run on 'Problem 2' page!
Sheets("Problem 2").Select
'Define Range of cells to scan
AllMaps = Range("B2:AB324").Value
'Set RowCounter starting position and start scanning
RowCntr = 2
Do Until Cells(RowCntr, 2).Value = "-9"
'Clear '-9' and leave cell empty
If Cells(RowCntr, 2).Value = "-9" Then
Cells(RowCntr, 2).ClearContents
End If
RowCntr = RowCntr + 1
Loop
Cells(RowCntr, 2).Value = AllMaps
Cells(RowCntr, 2).Value = RowCntr - 1
End Sub
Any help/tips would be greatly appreciated!!
I have data in cells B2:AB324 and would like the macro to scan/loop through all cells in range, to identify and clear the cell contents
for any cells containing the value of -9.
I have more than one sheet in this workbook, hence the specification; and so far, have come up with this (completely ineffective) code:
Sub ClearNeg9s()
'Clears all cells in range containing '-9'
'Turn off screen updating, for User aesthetics
Application.ScreenUpdating = False
'Only run on 'Problem 2' page!
Sheets("Problem 2").Select
'Define Range of cells to scan
AllMaps = Range("B2:AB324").Value
'Set RowCounter starting position and start scanning
RowCntr = 2
Do Until Cells(RowCntr, 2).Value = "-9"
'Clear '-9' and leave cell empty
If Cells(RowCntr, 2).Value = "-9" Then
Cells(RowCntr, 2).ClearContents
End If
RowCntr = RowCntr + 1
Loop
Cells(RowCntr, 2).Value = AllMaps
Cells(RowCntr, 2).Value = RowCntr - 1
End Sub