Skip to content

Commit

Permalink
Create Get_data.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Believe82 authored Apr 10, 2024
1 parent a5b3fef commit 3ee4dc6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Get_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Code to get data:

Sub get_data()
Dim PasteWs As Worksheet
Dim CopyWs As Worksheet
Dim LastRow
Dim LastColumn
'Code that will get the data:

'Opens the other workbook and sets the sheet to copy from
open_wb_onedrive
Set CopyWs = openwb.Worksheets("data")

'Set the sheet you would like to paste into:
Set PasteWs = ThisWorkbook.Worksheets("Sheet 1")

'clear contents of the paste area to make copy easier
PasteWs.Range("A1:AA100000").ClearContents

Application.ScreenUpdating = False

With CopyWs

'Finds the last Row and last Coloumn of our data
LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
LastColumn = .Cells(1, Columns.Count).End(xlToLeft).Column

'copy and paste the data from our data workbook to our main one
.Range(.Cells(1, 1), .Cells(LastRow, LastColumn)).Copy
PasteWs.Activate
PasteWs.Range("A1").Select
PasteWs.Paste

End With

'closes the data workbook and saves
openwb.Save
openwb.Close
objLogExcel.Quit

Application.ScreenUpdating = True
End Sub

0 comments on commit 3ee4dc6

Please sign in to comment.