Hello my Peers,
I have the below VBA code that will import to a worksheet, can I please get your advice on how do I amend the code so it creates a new worksheet per import and renames the tab with cell a3 from the imported worksheet.
Also is there anyway of keeping the structure of the inmported sheet/workbook and not remove any formatting?
I have searched for numerous VBA codes but failed to combine them for users using a mac.
[Sub Import()
Dim vFile As Variant
Dim wbCopyTo As Workbook
Dim wsCopyTo As Worksheet
Dim wbCopyFrom As Workbook
Dim wsCopyFrom As Worksheet
Set wbCopyTo = ActiveWorkbook
Set wsCopyTo = wbCopyTo.Sheets("InPutData")
Application.DisplayAlerts = False
vFile = Application.GetOpenFilename
If TypeName(vFile) = "Boolean" Then
Exit Sub
Else
Set wbCopyFrom = Workbooks.Open(vFile)
Set wsCopyFrom = wbCopyFrom.Worksheets(1)
Application.CutCopyMode = False
End If
Set oneRange = Range("A1:l1000")
Set aCell = Range("A1")
oneRange.Sort Key1:=aCell, Order1:=xlAscending, Header:=xlYes
wsCopyFrom.Range("A2:l1000").Copy
wsCopyTo.Range("A2").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
wbCopyFrom.Close False
End Sub]
I have the below VBA code that will import to a worksheet, can I please get your advice on how do I amend the code so it creates a new worksheet per import and renames the tab with cell a3 from the imported worksheet.
Also is there anyway of keeping the structure of the inmported sheet/workbook and not remove any formatting?
I have searched for numerous VBA codes but failed to combine them for users using a mac.
[Sub Import()
Dim vFile As Variant
Dim wbCopyTo As Workbook
Dim wsCopyTo As Worksheet
Dim wbCopyFrom As Workbook
Dim wsCopyFrom As Worksheet
Set wbCopyTo = ActiveWorkbook
Set wsCopyTo = wbCopyTo.Sheets("InPutData")
Application.DisplayAlerts = False
vFile = Application.GetOpenFilename
If TypeName(vFile) = "Boolean" Then
Exit Sub
Else
Set wbCopyFrom = Workbooks.Open(vFile)
Set wsCopyFrom = wbCopyFrom.Worksheets(1)
Application.CutCopyMode = False
End If
Set oneRange = Range("A1:l1000")
Set aCell = Range("A1")
oneRange.Sort Key1:=aCell, Order1:=xlAscending, Header:=xlYes
wsCopyFrom.Range("A2:l1000").Copy
wsCopyTo.Range("A2").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
wbCopyFrom.Close False
End Sub]