Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Function SheetExists(shtname As String, Optional wb As Workbook) As Boolean
  2.  
  3. Dim sht As Worksheet
  4.  
  5. If wb Is Nothing Then Set wb = ThisWorkbook
  6. On Error Resume Next
  7. Set sht = wb.Sheets(shtname)
  8. On Error GoTo 0
  9. SheetExists = Not sht Is Nothing
  10.  
  11. End Function
  12.  
  13.  
  14. Sub macro()
  15.  
  16. Dim xRow As Integer
  17. Dim xCol As Integer
  18. Dim MyRange As Range
  19.  
  20. Set MyRange = Sheets("Dataset").UsedRange
  21. xRow = MyRange.Rows.Count
  22. xCol = MyRange.Columns.Count
  23.  
  24.  
  25. If SheetExists("Summary") = 0 Then
  26. Worksheets.Add
  27. ActiveSheet.Name = "Summary"
  28. Else
  29. Sheets("Summary").Select
  30. End If
  31.  
  32.  
  33. Range("A1").Value = xRow
  34. Range("A2").Value = xCol
  35.  
  36.  
  37. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement