Copy range to next free row in a different sheet - vba

I need to copy a range (Sheet2 B2:S2), paste it on the same sheet on the first free row after row 7, paste the same data to the first empty row on Sheet1 and then clear the contents of the original range (Sheet2 B2:S2) ready for the next entry.
I have tried to use other posts but I can't figure out what to do.
Here is the macro that does the easy bit
Sub Macro2()
'
' Macro2 Macro
'
'
Sheets("Sheet2").Select
Range("B2:S2").Select
Selection.Copy
Range("B7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("B2:S2").Select
Application.CutCopyMode = False
Selection.ClearContents
End Sub
It pastes over the last line. I need it to find the next free line when pasting.

You're so close! The issue is that you never increment the destination range object -- it's always set to Range("B7"). The following heavily-commented code should achieve what you're after:
Option Explicit
Public Sub MoveRowFrom2To1()
Dim shtSource As Worksheet, shtResult As Worksheet
Dim rngSource As Range, rngResult As Range
Dim lngLastRowOnSheet1 As Long, lngLastRowOnSheet2 As Long
'Set references up-front
Set shtSource = ThisWorkbook.Worksheets("Sheet2")
Set shtResult = ThisWorkbook.Worksheets("Sheet1")
'Identify the last occupied row on Sheet1 and Sheet2
lngLastRowOnSheet1 = LastRowNum(shtResult)
lngLastRowOnSheet2 = LastRowNum(shtSource)
'If the last occupied row is < 7, default to 6 so it writes to 7
If lngLastRowOnSheet2 < 7 Then
lngLastRowOnSheet2 = 6
End If
'Identify the Source data and Sheet2 Destination
Set rngSource = shtSource.Range("B2:S2")
Set rngResult = shtSource.Cells(lngLastRowOnSheet2 + 1, 2) '<~ column 2 is B
'Copy the Source data from Sheet2 to lower on Sheet2
rngSource.Copy
rngResult.PasteSpecial (xlPasteValues)
'Identify the Sheet1 Destination
Set rngResult = shtResult.Cells(lngLastRowOnSheet1 + 1, 2) '<~ column 2 is B
'Paste the Source data from Sheet2 onto Sheet1
rngResult.PasteSpecial (xlPasteValues)
'Clear the Source range in anticipation of a new entry
rngSource.ClearContents
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'INPUT : Sheet, the worksheet we'll search to find the last row
'OUTPUT : Long, the last occupied row
'SPECIAL CASE: if Sheet is empty, return 0
Public Function LastRowNum(Sheet As Worksheet) As Long
If Application.WorksheetFunction.CountA(Sheet.Cells) <> 0 Then
LastRowNum = Sheet.Cells.Find(What:="*", _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Else
LastRowNum = 0
End If
End Function

Try this, have tidied up by removing your select statements:
Sub Macro2()
Dim SourceRange, TargetRange1, TargetRange2 As Range
Dim RowToPaste As Long
'set range of source data
Set SourceRange = Sheets("Sheet2").Range("B2:S2")
'cater for chance that less than 7 rows are populated - we want to paste from row 8 as a minimum
If (Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row + 1) < 8 Then
RowToPaste = 8
Else
'Add 1 to the value of the last populated row
RowToPaste = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row + 1
End If
'Set the address of the target 1 range based on the last populated row in column B
Set TargetRange1 = Sheets("Sheet2").Range("B" & RowToPaste)
'Copy Source to target 1
SourceRange.Copy Destination:=TargetRange1
'Cater for Sheet 1 being totally empty and set target row to 1
If Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row = 1 And _
Len(Sheets("Sheet1").Range("A1")) = 0 Then
RowToPaste = 1
Else 'set target row to last populated row + 1
RowToPaste = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row + 1
End If
'Set the target 2 range based on the last empty row in column A
Set TargetRange2 = Sheets("Sheet1").Range("A" & RowToPaste)
'Paste the source to target 2
SourceRange.Copy Destination:=TargetRange2
'Clear the source data
SourceRange.ClearContents
End Sub

Related

Creating a new worksheet and naming it only if a sheet by that name does not exist already

I am not sure if I am performing this operation the most effectively, but I am attempting to copy products into newly created sheets if they are the same product.
For example if there are 4 products that are "Apples" and two that are "Oranges". Then I would like to create a new sheet for each product, rename the new sheet after said product, and place each row containing said product into each new sheet.
Currently, my program is running through a double loop. The first loop runs through each row in the first sheet, and the second loops through the sheet names.
The problem I am running into is with the first loop: the code creates a new sheet for the first product in the list, which is fine. But the next product in the list is the same product, so it should be placed into the newly-created sheet. However, my code creates another new sheet, attempts to rename it after the product next in the list, and then errors and says
"You can't name the sheet after a sheet named the same thing".
Now that is a Catch-22, because my if statement should catch it, but it doesn't.
I am running this is an outside workbook, after the program runs, I will save it under a different file name, so I'd prefer not to paste the date into the macro file and just keep it as a separate file.
CODE:
Dim fd As FileDialog
Dim tempWB As Workbook
Dim i As Integer
Dim rwCnt As Long
Dim rngSrt As Range
Dim shRwCnt As Long
Set fd = Application.FileDialog(msoFileDialogFilePicker)
For i = 1 To fd.SelectedItems.Count
Set tempWB = Workbooks.Open(fd.SelectedItems(i))
With tempWB.Worksheets(1)
For y = 3 To rwCnt
For Z = 1 To tempWB.Sheets.Count
If .Cells(y, 2).Value = tempWB.Sheets(Z).Name Then
.Rows(y).Copy
shRwCnt = tempWB.Worksheets(Z).Cells(Rows.Count, 1).End(xlUp).Row
tempWB.Worksheets(Sheets.Count).Range("A" & shRwCnt).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ElseIf tempWB.Sheets(Z).Name <> .Range("B" & y).Value Then
If Z = tempWB.Sheets.Count Then
.Range("A1:AQ2").Copy
tempWB.Worksheets.Add after:=tempWB.Worksheets(Sheets.Count)
tempWB.Worksheets(Sheets.Count).Name = .Cells(y, 2).Value
tempWB.Worksheets(Sheets.Count).Range("A1").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Rows(y).Copy
tempWB.Worksheets(Sheets.Count).Range("A3").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
End If
Next Z
Next y
End With
Next i
You need 1 loop to go through all rows of the sheet you want to scan. In this loop check if a sheet with the product name exists. If it exists find the next free row in it and past your data. If it does not exists add a sheet with that product name and paste in row 1.
Note that you can only use the left 31 characters of the product name for your worksheet names. Worksheet names have a limit.
Dim WsDest As Worksheet
For i = 1 To fd.SelectedItems.Count
Set tempWB = Workbooks.Open(fd.SelectedItems(i))
With tempWB.Worksheets(1)
For y = 3 To rwCnt
Set WsDest = Nothing
On Error Resume Next 'next line throws an error if the ws does not exist so hide errors
Set WsDest = Worksheets(Left$(.Cells(y, 2).Value, 31)) 'worksheet names are limited to 31 characters
On Error GoTo 0 're-activate error reporting
If WsDest Is Nothing Then 'if ws does not exist
'add this sheet name it and copy/paste
Set WsDest = Worksheets.Add
WsDest.Name = Left$(.Cells(y, 2).Value, 31) 'worksheet names are limited to 31 characters
.Rows(y).Copy
WsDest.Cells(1, 1).Paste
Else
'find last used row and copy/paste
shRwCnt = WsDest.Cells(WsDest.Rows.Count, 1).End(xlUp).Row
.Rows(y).Copy
WsDest.Cells(shRwCnt + 1, 1).Paste
End If
Next y
End With
Next i
Quick answer: Instead of looping through the existing sheets, you should see if the sheet you want exists, then just go there. Something like this:
For i = 1 To fd.SelectedItems.Count
If WorksheetExists(.Cells(y, 2).Value) Then'
'Copy the data into the existing sheet
end if
Next i
For the WorksheetExists function, see Test or check if sheet exists
As others have noted, you need to check all sheet names before you take action, but I recommend adding a function that stores the names of the worksheets into a dictionary to speed that process up. I did my best to update your code with this accordingly.
Function get_worksheet_names() As Object
Dim d As Object _
, sht As Worksheet
Set d = CreateObject("Scripting.Dictionary")
For Each sht In ThisWorkbook.Sheets
d.Add sht.Name, sht.Index
Next sht
Set get_worksheet_names = d
End Function
Sub update_workbook_sheets()
Dim fd As FileDialog
Dim tempWB As Workbook
Dim i As Integer
Dim sht_dict As Object
Dim tmpSht As Worksheet
Dim rwCnt As Long
Dim rngSrt As Range
Dim shRwCnt As Long
Set sht_dict = get_worksheet_names() 'get dictionary of sheets
Set fd = Application.FileDialog(msoFileDialogFilePicker)
For i = 1 To fd.SelectedItems.Count
Set tempWB = Workbooks.Open(fd.SelectedItems(i))
With tempWB.Worksheets(1)
For y = 3 To rwCnt
If sht_dict.Exists(.Cells(y, 2).Value) Then 'If sheet exists
.Rows(y).Copy
shRwCnt = tempWB.Worksheets(Z).Cells(Rows.Count, 1).End(xlUp).Row
tempWB.Worksheets(Sheets.Count).Range("A" & shRwCnt).PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Else 'if sheet does not exist
.Range("A1:AQ2").Copy
tempWB.Worksheets.Add after:=tempWB.Worksheets(Sheets.Count)
tempWB.Worksheets(Sheets.Count).Name = .Cells(y, 2).Value
tempWB.Worksheets(Sheets.Count).Range("A1").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Rows(y).Copy
tempWB.Worksheets(Sheets.Count).Range("A3").PasteSpecial Paste:=xlPasteAllUsingSourceTheme, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Set sht_dict = get_worksheet_names()
End If
Next y
End With
Next i
End Sub

How to properly code offset in a copy paste loop VBA

I'm trying to copy then paste into cells in a loop. Using cell BP3 as an original reference im trying to write it such that after each iteration it pastes into the next cell down from BP3 i.e BP4. But I currently just repeats in cell BP4.
' Copy and Paste of CAPEX 4 forecast dates from VR all DVs
Dim Updated_Spreadsheet As Workbook
Dim wb As Workbook: Set wb = Workbooks("study tracker.xlsm")
Set Updated_Spreadsheet = Workbooks("VR.xlsm")
Set sht = Updated_Spreadsheet.Sheets("Variance Report")
Set sht2 = wb.Sheets("Environmental Studies")
'Loop
Dim cell As Range, lRow As Long, NextRow As Long, lngDataRows As Long
For Each cell In sht2.Range("A3", sht2.Range("A" & Rows.Count).End(xlDown))
'specifying cell i want to use as a criteria for the filter
'cell = sht2.Range("A3").Value
sht.Activate
'specifying filter range
sht.Range("$A$7:$GV$4694").AutoFilter Field:=1, Criteria1:=cell
'specifying the exact cell from the filter which I would like to copy
sht.UsedRange.SpecialCells _
(xlCellTypeVisible).Areas(2).Columns(171).Cells(1, 1).Copy
wb.Activate
'pasting into new location
lngDataRows = cell.CurrentRegion.Rows.Count - 1
Range("BP3").Offset(lngDataRows + 1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next cell
You're only getting cell "BP4" because every time your loop runs you're selecting the same cell over and over again.
Initiate a variable (before starting your loop) that will increase in value with each loop iteration.
OffsetBy = 1
'Your "For Each" loop starts here
'(...)
'Use this variable in here:
Range("BP3").Offset(lngDataRows + OffsetBy, 0).Select
OffsetBy = OffsetBy + 1
Next cell
Hope this helps!

Copy & Paste into next empty row & column respectively

I asked a number of times on this question & all the while, I being given vague answer, which isn't much help. Thus I just research on my own and came up with the following code from my research. Which works but doesn't exactly give me the desired outcome stated in the image attached. Whereby the codes paste the data from its specified cells but paste in column A which isn't the outcome wanted, but rather to paste from column B onward for sheets DX,DY & DZ.
Is there also a way I can get column A to update the date by itself base on Date entered in cell S9 which tag along with the data for sheets DX,DY & DZ. Likewise for sheet RAW, that update row 6 with the date entered in S9 of sheet GP Data
Sub Prism2ndStep()
'
' Prism2ndStep Macro
'
r = 1
Sheets("GP Data").Range("S12:S14").Copy
If Sheets("GP Data").Range("S12") = Sheets("DX").Range("A65536").End(xlUp) _
Then r = 0
Sheets("DX").Range("A65536").End(xlUp).Offset(r, 0).PasteSpecial _
Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
j = 1
Sheets("GP Data").Range("T12:T14").Copy
If Sheets("GP Data").Range("T12") = Sheets("DX").Range("A65536").End(xlUp) _
Then j = 0
Sheets("DX").Range("A65536").End(xlUp).Offset(j, 0).PasteSpecial _
Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
k = 1
Sheets("GP Data").Range("U12:U14").Copy
If Sheets("GP Data").Range("U12") = Sheets("DX").Range("A65536").End(xlUp) _
Then k = 0
Sheets("DX").Range("A65536").End(xlUp).Offset(k, 0).PasteSpecial _
Paste:=xlPasteValues, Transpose:=True
Application.CutCopyMode = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("GP Data")
Set pasteSheet = Worksheets("RAW")
copySheet.Range("P12:R14").Copy
With pasteSheet
.Cells(7, .Columns.Count).End(xlToLeft).Offset(0, 7).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
End Sub
Try this macro for copying data from "GP Data" S12:S14 and pasting it into column B:D in DX tab.
Edited
Sub prism2ndStep()
'get date from cell p9
strdate = Sheets("GP Data").Range("S9").Value
arrData = Sheets("GP Data").Range("S12:S14").Value
Set rngwrite = Nothing
Set rngwrite = Sheets("DX").Range("A:A").Find(strdate, LookIn:=xlFormulas)
Do While rngwrite Is Nothing
With Sheets("DX").Range("A60000")
.End(xlUp).AutoFill (.End(xlUp).Resize(2))
End With
Set rngwrite = Sheets("DX").Range("A:A").Find(CDate(strdate), LookIn:=xlFormulas)
Loop
rngwrite.Offset(, 1).Resize(, 3).Value = Application.Transpose(arrData)
End Sub
Sub prism2ndStep2()
'get data
arrData = Sheets("GP Data").Range("P12:R14").Value
'find get the first non-blank column in row 7 from right to left
Set rngwrite = Sheets("RAW").Range("IV7").End(xlToLeft).Offset(, 1)
'paste data
rngwrite.Resize(3, 3).Value = arrData
'drag dates across row 7
rngwrite.Offset(-1).Value = rngwrite.Offset(-1, -3).Value + 1
End Sub

VBA: Build a Table by (Copy/Paste) by Using Criteria to Select Rows, Then Specifiy Columns

I want to build a table on one Excel Sheet "Ship" by pulling data from another excel sheet "Efficiency." The row data on the "Efficiency" sheet is categorized by "Shipped", "Leave", "Import" and "Export".
Each category (shipped, leave, import, export) has several items and they're in no specific order. The table on the "Efficiency" sheet occupies columns A:H, and starts at row 2; the length can vary.
I want to be able to search the rows for "Shipped" and copy columns A, D:F and H of the matching rows and paste them beginning at cell B4 of the "Ship" sheet. Can anyone help me please?
Sub Ship()
ActiveSheet.Range("$A$1:$H$201").AutoFilter Field:=4, Criteria1:="Shipped"
' this is looking in a specific range, I want to make it more dynamic
Range("A4:A109").Select
'This is the range selected to copy, again I want to make this part more dynamic
Application.CutCopyMode = False
Selection.Copy
Range("A4:A109,D4:F109,H4:H109").Select
Range("G4").Activate
Application.CutCopyMode = False
Selection.Copy
Sheets("Ship").Select
Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
This code has been tested based on your the information as given in your question:
Sub Ship()
Dim wsEff As Worksheet
Dim wsShip As Worksheet
Set wsEff = Worksheets("Efficiency")
Set wsShip = Worksheets("Shipped")
With wsEff
Dim lRow As Long
'make it dynamic by always finding last row with data
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
'changed field to 2 based on your above comment that Shipped is in column B (the code you posted has 4).
.Range("A1:H" & lRow).AutoFilter Field:=2, Criteria1:="Shipped"
Dim rngCopy As Range
'only columns A, D:F, H
Set rngCopy = Union(.Columns("A"), .Columns("D:F"), .Columns("H"))
'filtered rows, not including header row - assumes row 1 is headers
Set rngCopy = Intersect(rngCopy, .Range("A1:H" & lRow), .Range("A1:H" & lRow).Offset(1)).SpecialCells(xlCellTypeVisible)
rngCopy.Copy
End With
wsShip.Range("B4").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
try the below code
Sub runthiscode()
Worksheets("Efficiency").Select
lastrow = Range("A" & Rows.Count).End(xlUp).Row
startingrow = 4
For i = 2 To lastrow
If Cells(i, 2) = "Shipped" Then
cella = Cells(i, 1)
celld = Cells(i, 4)
celle = Cells(i, 5)
cellf = Cells(i, 6)
cellh = Cells(i, 8)
Worksheets("Ship").Cells(startingrow, 2) = cella
Worksheets("Ship").Cells(startingrow, 5) = celld
Worksheets("Ship").Cells(startingrow, 6) = celle
Worksheets("Ship").Cells(startingrow, 7) = cellf
Worksheets("Ship").Cells(startingrow, 9) = cellh
startingrow = startingrow + 1
End If
Next i
End Sub

Use VBA to paste values from one table to another

I have the following VBA code that takes a single row from Sheet "Tabled data", copies the data, then pastes the data into the next available row in Sheet "Running list". However the original row has formulas and I need the values to paste, not the formulas. I've seen numerous ways to do it with Range.PasteSpecial but this code didn't use Range and I'm not sure how to incorporate it.
Note: I modified this code from here: http://msdn.microsoft.com/en-us/library/office/ff837760(v=office.15).aspx. It originally had an IF statement to match content in a cell then paste it in a certain sheet according to the content in the cell. I only had one sheet to copy to and didn't need the IF. I don't really need to find the last row of data to copy either as it will only ever be one row with range of A2:N2. But if I take out the FinalRow section and the For and replace with Range("A2:N2") it doesn't work so I left those in.
Any guidance on how to add in the PasteValues property without making this more complicated? I'm also open to simplification of the For or FinalRow variable such as using Range. I'm only sort of familiar with VBA, having done a few things with it, but usually after much searching and modifying code.
Public Sub CopyData()
Sheets("Tabled data").Select
' Find the last row of data
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row
For x = 2 To FinalRow
ThisValue = Cells(x, 1).Value
Cells(x, 1).Resize(1, 14).Copy
Sheets("Running list").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
Sheets("Tabled data").Select
Next x
End Sub
Hopefully we can actually make this more simple.
Public Sub CopyRows()
Sheets("Sheet1").UsedRange.Copy
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
'check if the last cell found is empty
If IsEmpty(ActiveSheet.Cells(lastrow, 1)) = True Then
'if it is empty, then we should fill it
nextrow = lastrow
Else
'if it is not empty, then we should not overwrite it
nextrow = lastrow + 1
End If
ActiveSheet.Cells(nextrow, 1).Select
ActiveSheet.Paste
End Sub
edit: I expanded it a little so that there won't be a blank line at the top
I found a working solution. I recorded a macro to get the paste special in there and added the extra code to find the next empty row:
Sub Save_Results()
' Save_Results Macro
Sheets("Summary").Select 'renamed sheets for clarification, this was 'Tabled data'
'copy the row
Range("Table1[Dataset Name]").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
' paste values into the next empty row
Sheets("Assessment Results").Select
Range("A2").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(NextRow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Return to main sheet
Sheets("Data Assessment Tool").Select
End Sub
Just copy the data all at once, no need to do it a row at a time.
Sub CopyData()
With ThisWorkbook.Sheets("Tabled data")
Dim sourceRange As Range
Set sourceRange = .Range(.Cells(2, 1), .Cells(getLastRow(.Range("A1").Parent), 14))
End With
With ThisWorkbook.Sheets("Running list")
Dim pasteRow As Long
Dim pasteRange As Range
pasteRow = getLastRow(.Range("A1").Parent) + 1
Set pasteRange = .Range(.Cells(pasteRow, 1), .Cells(pasteRow + sourceRange.Rows.Count, 14))
End With
pasteRange.Value = sourceRange.Value
End Sub
Function getLastRow(ws As Worksheet, Optional colNum As Long = 1) As Long
getLastRow = ws.Cells(ws.Rows.Count, colNum).End(xlUp).Row
End Function
Private Sub Load_Click()
Call ImportInfo
End Sub
Sub ImportInfo()
Dim FileName As String
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Dim ActiveListWB As Workbook
Dim check As Integer
'Application.ScreenUpdating = False
Set WS2 = ActiveWorkbook.Sheets("KE_RAW")
confirm = MsgBox("Select (.xlsx) Excel file for Data transfer." & vbNewLine & "Please ensure the sheets are named Sort List, Second and Third.", vbOKCancel)
If confirm = 1 Then
FileName = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*),*.xls*", _
Title:="Select Active List to Import", MultiSelect:=False)
If FileName = "False" Then
MsgBox "Import procedure was canceled"
Exit Sub
Else
Call CleanRaw
Set ActiveListWB = Workbooks.Open(FileName)
End If
Set WS1 = ActiveListWB.Sheets("Sort List")
WS1.UsedRange.Copy 'WS2.Range("A1")
' WS2.Range("A1").Select
WS2.UsedRange.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'WS2.Range ("A1")
ActiveWorkbook.Close False
'Call ClearFormulas
' Call RefreshAllPivotTables
Sheets("Key Entry Data").Select
'Sheets("Raw").Visible = False
'Application.ScreenUpdating = True
MsgBox "Data has been imported to workbook"
Else
MsgBox "Import procedure was canceled"
End If
Application.ScreenUpdating = True
End Sub
Sub CleanRaw()
Sheets("KE_RAW").Visible = True
Sheets("KE_RAW").Activate
ActiveSheet.Cells.Select
Selection.ClearContents
End Sub