The Excel VBA macro below will create a new Excel Worksheet called ‘RawData’ or we can use msgbox to ask for the Worksheet name if needed.
If there is already a Worksheet called RawData, user will be ask whether they want to use the old Worksheet and cancel new Worksheet creation, or delete the old Worksheet and continue creating a new blank Worksheet.
Sub CreateNewWorksheet()
Dim oSheet As Worksheet, vRet As Variant
On Error GoTo errHandler
'creating a new excel worksheet called RawData
Set oSheet = Worksheets.Add
With oSheet
.Name = "RawData"
.Cells(1.1).Select
.Activate
End With
Exit Sub
errHandler:
'if error due to duplicate worksheet detected
If Err.Number = 1004 Then
'display an options to user
vRet = MsgBox("Worksheet called 'RawData' is already exist, " & _
"click yes to continue creating new Worksheet and delete the old one, " & _
"or click no to go to the old worksheet.", _
vbOKCancel, "Duplicate Worksheet")
If vRet = vbOK Then
'delete the old worksheet
Application.DisplayAlerts = False
Worksheets("RawData").Delete
Application.DisplayAlerts = True
'rename and activate the new worksheet
With oSheet
.Name = "RawData"
.Cells(1.1).Select
.Activate
End With
Else
'cancel the operation, delete the new worksheet
Application.DisplayAlerts = False
oSheet.Delete
Application.DisplayAlerts = True
'activate the old worksheet
Worksheets("RawData").Activate
End If
End If
End Sub
Hi
I want to write a macro that counts the following
Number of cells with formulae
Number of Rows with data/formulae
Number of Columns with data/formulae
Please let me know if there is a way of doing it in Excel VBA
Pingback: Number of Cells/Rows/Columns With Formula | Excel VBA Macro Tutorial and Examples
Hi LS, please find your answer here.
Pingback: Bail Bonds Los Angeles
Pingback: debt consolidation companies
Pingback: de reverse mortgage
Pingback: debt consolidation company
Pingback: debt consolidation loans
Pingback: consolidation loans
Pingback: reverse mortgage costs
Pingback: air treatment systems
Pingback: The Number One Article on Project Management Gantt Charts
Pingback: debt collection rate
Pingback: Wedding photographer services calgary
Pingback: collection agency rates
Pingback: verona relais
Pingback: buy usb bear
Pingback: collection agency
Pingback: Club de fans de Selena Gomez
Pingback: collection agency newsletter
Pingback: Sammelkarten
Pingback: Printable Laundry Detergent Coupons 2012
Pingback: online free credit report
Pingback: wedding photographer calgary
Pingback: tatuaggi maori
Pingback: Pearl Izumi Running Shoe Deals
Pingback: meer info
Pingback: pick up lines for guys to use on girls
Pingback: cushion cut egagement ring
Pingback: Erotiek Groothandel
Pingback: Kutjes
Pingback: landscape gardeners north london
Pingback: free microsoft points generator
Pingback: Radiologist schools in Maryland
Pingback: Custom CRM
Pingback: Outdoor Signs
Pingback: walmart credit card
Pingback: bermuda homme
Pingback: ????? paypal ????????????
Pingback: phlebotomy training
Pingback: SEO Services Plans
Pingback: hobby lobby
Pingback: SEO Services
Pingback: home depot coupons
Pingback: chota bheem games
Pingback: Aeropostale coupons
Pingback: Bed Bath and Beyond Canada
Pingback: amazon coupon code
Pingback: ????? ?????????????
Pingback: Kung Fu Panda Games