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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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