Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SheetExists(shtname As String, Optional wb As Workbook) As Boolean
- Dim sht As Worksheet
- If wb Is Nothing Then Set wb = ThisWorkbook
- On Error Resume Next
- Set sht = wb.Sheets(shtname)
- On Error GoTo 0
- SheetExists = Not sht Is Nothing
- End Function
- Sub macro()
- Dim xRow As Integer
- Dim xCol As Integer
- Dim MyRange As Range
- Set MyRange = Sheets("Dataset").UsedRange
- xRow = MyRange.Rows.Count
- xCol = MyRange.Columns.Count
- If SheetExists("Summary") = 0 Then
- Worksheets.Add
- ActiveSheet.Name = "Summary"
- Else
- Sheets("Summary").Select
- End If
- Range("A1").Value = xRow
- Range("A2").Value = xCol
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement