Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Dim sh As Worksheet, sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  2. Dim wb As Workbook, wb1 As Workbook, wb2 As Workbook, wb3 As Workbook
  3.  
  4. wb.Activate
  5.  
  6. 'Clears sheet contents
  7. sh1.Cells.ClearContents
  8. sh2.Cells.ClearContents
  9. sh3.Cells.ClearContents
  10.  
  11. 'Applies filter to main file to categories based on who can see it, then pastes into different sheets
  12. With sh.Range("A2", "H300")
  13. .AutoFilter
  14. .AutoFilter Field:=1, Criteria1:="N", Operator:=xlOr, Criteria2:="Y"
  15. .Copy sh1.Range("A1")
  16. .AutoFilter Field:=1, Criteria1:="D", Operator:=xlOr, Criteria2:="Y"
  17. .Copy sh2.Range("A1")
  18. .AutoFilter Field:=1, Criteria1:="Y"
  19. .Copy sh3.Range("A1")
  20. .AutoFilter
  21. End With
  22.  
  23. 'Copy filtered sheets from main file onto dropbox files(update) then saves and closes the file
  24. sh1.Cells.Copy
  25. wb1.Sheets("Sheet1").Cells.PasteSpecial
  26. wb1.Sheets("Sheet1").Range("A1:H300").Locked = True
  27. wb1.Save
  28. wb1.Close
  29.  
  30. sh2.Cells.Copy
  31. wb2.Sheets("Sheet1").Cells.PasteSpecial
  32. wb2.Sheets("Sheet1").Range("A1:H300").Locked = True
  33. wb2.Save
  34. wb2.Close
  35.  
  36. sh3.Cells.Copy
  37. wb3.Sheets("Sheet1").Cells.PasteSpecial
  38. wb3.Sheets("Sheet1").Range("A1:H300").Locked = True
  39. wb3.Save
  40. wb3.Close
  41.  
  42. MsgBox ("Dropbox has been updated")
  43.  
  44. Dim sh As Worksheet, sh1 As Worksheet, sh2 As Worksheet, sh3 As Worksheet
  45. Dim wb As Workbook, wb1 As Workbook, wb2 As Workbook, wb3 As Workbook
  46.  
  47. 'Name of workbooks in dropbox
  48. Set wb1 = Workbooks("abc.xlsx")
  49. Set wb2 = Workbooks("abcdefghij.xlsx")
  50. Set wb3 = Workbooks("abcdeghjklm.xlsx")
  51.  
  52. wb.Activate
  53.  
  54. 'Clears sheet contents
  55. sh1.Cells.ClearContents
  56. sh2.Cells.ClearContents
  57. sh3.Cells.ClearContents
  58.  
  59. 'Copy data from xxxxxxxxxx information sheet
  60. wb1.Sheets("sheet1").Cells.Copy
  61. sh1.Cells.PasteSpecial
  62.  
  63. 'Copy data from xxxxxxxx information sheet
  64. wb2.Sheets("sheet1").Cells.Copy
  65. sh2.Cells.PasteSpecial
  66.  
  67. 'Copy data from xxx xxxxxxxxx information sheet
  68. wb3.Sheets("sheet1").Cells.Copy
  69. sh3.Cells.PasteSpecial
  70.  
  71. 'Name sheets in main file
  72. sh1.Name = "xxxxxxxxx"
  73. sh2.Name = "Dxxxxxxx"
  74. sh3.Name = "Dxx Dxxxxxxxxx"
  75.  
  76. MsgBox ("Download complete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement