Advertisement
Guest User

Untitled

a guest
Aug 25th, 2013
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Dim WS As Worksheet
  2.  
  3. Set WS = Sheets.Add(After:=Sheets(Worksheets.count))
  4. WS.name = txtSheetName.value
  5.  
  6. Dim WS As Worksheet
  7. MsgBox (WS Is Nothing)
  8.  
  9. Set WS = Sheets.Add(After:=Sheets(Worksheets.count))
  10. '***** Nothing after this point gets processed *******
  11. MsgBox (WS Is Nothing)
  12. MsgBox WS.name
  13.  
  14. WS.name = txtSheetName.value
  15. MsgBox WS.name
  16.  
  17. Dim WS as Worksheet
  18. Set WS = Sheets.Add
  19.  
  20. You don't have to know where is it located, what's it's name, you just refer to it as WS.
  21.  
  22. If you still want to do this the "old fashioned" way, try this:
  23.  
  24. Sheets.Add.Name = "Test"
  25.  
  26. Dim WS As Worksheet
  27. Dim i As Long
  28.  
  29. With ThisWorkbook
  30. Set WS = .Worksheets.Add(After:=.Sheets(.Sheets.Count))
  31. End With
  32.  
  33. For i = 1 To 1000
  34. DoEvents
  35. Next i
  36.  
  37. WS.Name = txtSheetName.Value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement