rudolfweyers
New Member
- Joined
- Nov 22, 2021
- Messages
- 6
- Office Version
- 2019
- Platform
- Windows
Good day
Currently I have a module that will run through a workbook, and on each sheet change a range of cells from general to number.
It works well if all the sheets are in the workbook. Some projects wont have all the sheets, so my code then gets stuck as the sheet doesn't exist.
Im thinking of using the an If statement to check if the sheet exist, if so, run the code to change the cells, else move on to check if the next sheet exist.
So far I haven't been able to figure it out.
Here is a piece of the code for a couple of the sheets.
Sub Selection()
'
' Selection Macro
'
'
Sheets("BOQ_Door Handle Schedule").Select
With Range("C2:D500")
.NumberFormat = "General"
.Value = .Value
End With
Sheets("BOQ_Earthwork Cut & Fill").Select
With Range("E2:F500")
.NumberFormat = "General"
.Value = .Value
End With
Sheets("BOQ_Electrical Installation Sch").Select
With Range("C3:D1000")
.NumberFormat = "General"
.Value = .Value
End With
End Sub
Currently I have a module that will run through a workbook, and on each sheet change a range of cells from general to number.
It works well if all the sheets are in the workbook. Some projects wont have all the sheets, so my code then gets stuck as the sheet doesn't exist.
Im thinking of using the an If statement to check if the sheet exist, if so, run the code to change the cells, else move on to check if the next sheet exist.
So far I haven't been able to figure it out.
Here is a piece of the code for a couple of the sheets.
Sub Selection()
'
' Selection Macro
'
'
Sheets("BOQ_Door Handle Schedule").Select
With Range("C2:D500")
.NumberFormat = "General"
.Value = .Value
End With
Sheets("BOQ_Earthwork Cut & Fill").Select
With Range("E2:F500")
.NumberFormat = "General"
.Value = .Value
End With
Sheets("BOQ_Electrical Installation Sch").Select
With Range("C3:D1000")
.NumberFormat = "General"
.Value = .Value
End With
End Sub