Skip to content

Instantly share code, notes, and snippets.

@Tejkaran
Last active August 3, 2019 11:07
Show Gist options
  • Save Tejkaran/befa0959eea1cbb16dfe0301b5866bf7 to your computer and use it in GitHub Desktop.
Save Tejkaran/befa0959eea1cbb16dfe0301b5866bf7 to your computer and use it in GitHub Desktop.
friend help
Option Explicit
Sub Sams_awesome_macro()
'this sets the name of your workbooks and worksheets, so you can call them quickly rather than writing the name
'of the workbook or worksheet everytime. You had made and "object" of the workbooks/worksheet
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
'This bit defines what the names refer to, so every time you call wbk1, it refers to the Sub Cat Stores Workbook
'I assume the macro is running from the Space Data Condensed workbook?
Set wbk1 = Workbooks.Open("U:/Space Data/Sub Cat Store Grades.xlsm", ReadOnly:=True)
Set wbk2 = Workbooks("Space Data Condensed.xlsm")
'This defines what the worksheets are, so every time you call ws1, it refers to the sheet called Grades which is in the Sub Cat Stores Grades workbook
Set ws1 = wbk1.Sheets("Grades")
Set ws2 = wbk1.Sheets("Paste Space Data")
Set ws3 = wbk1.Sheets("Note Checker")
'This speeds up the whole process by turning off anythong which is not needed whilst the macro is running.
'For example calculate is done every time anything changes, by turning this off , it will only calculate stuff once it is turned back on
'which speeds things up a lot
Call Speed_up
ws1.Cells.Copy 'copy all the cells from Grades
ws2.Cells.PasteSpecial (xlPasteAll) 'paste in Paste SPace Data
With ws2
.Range("B3") = 2
.Range("C3") = 3
.Range("D3") = 4
.Range("B3:D3").AutoFill Destination:=Range("B3:F3"), Type:=xlFillDefault
End With
'This will be the sheet you want to be viewing when the macro ends
'At the moment it is note checker cell A1
ws3.Range("A1").Select
'This turns on all the things you turned off at the beginning
Call Slow_Down
End Sub
Sub Speed_up()
Application.DisplayAlerts = False
Application.Calculate = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
End Sub
Sub Slow_Down()
Application.DisplayAlerts = True
Application.Calculate = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment