Help with Amending VBA Mac code

Fuisdale2

Board Regular
Joined
Mar 28, 2017
Messages
57
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]
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top