Copy/Paste Data and formatting any user PC & MAC save as Dialog box prompt

JarrydNAR

New Member
Joined
Nov 21, 2021
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hi all, Hoping someone can help here

I have a VBA Script that i have put together that Already Copy and Pastes Data and formatting that I use internally. I'm looking to re use this Script for a similar purpose for External Sales Reps

Effectively I need it to Extract a Cell Range into a new file, Paste Data, Paste Formatting and save the file. there will be multiple users some using PC some using MAC versions of Excel. i was thinking the easiest method would be to have while the Script is processing the Copy and Paste process it prompts the Save As Dialog box for the user to define where they want the file Saved

Below is the Script I am currently using for my own file

I have done a lot of googling but cant seem to make sense of the functions needed to prompt for the Save as Dialog box

all help appreciated,

Cheers


Sub CopyData()
Dim wbI As Workbook, wbO As Workbook
Dim wsI As Worksheet, wsO As Worksheet

Set wbI = ThisWorkbook
'~~> Set the relevant sheet from where you want to copy
Set wsI = wbI.Sheets("Sheet1")

Set wbO = Workbooks.Add

With wbO
'~~> Set the relevant sheet to where you want to paste
Set wsO = wbO.Sheets("Sheet1")

.SaveAs Filename:="T:\Templates\Contract Report Output\Book2.xls", FileFormat:=56

wsI.Range("=A:T,X:AA").Copy

wsO.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

wsO.Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Bump.

Let me know if any other info is needed to assist on this one

Cheers
 
Upvote 0
Hi,​
use the VBA method GetSaveAsFilename like you can see in VBA help …​
 
Upvote 0
Hi,​
use the VBA method GetSaveAsFilename like you can see in VBA help …​

So if i wanted to Nest this in the VBA Process i have above do i need to nest it before the copy and past functions?
 
Upvote 0
So if i wanted to Nest this in the VBA Process i have above do i need to nest it before the copy and past functions?

So i got tis to work on PC but it throws a 400 Error on MAC

Is there something that can be added/changed for this function to Work on Excel on MAC users computers?



Sub ETAExtract()
Dim wbI As Workbook, wbO As Workbook
Dim wsI As Worksheet, wsO As Worksheet


Set wbI = ThisWorkbook
'~~> Set the relevant sheet from where you want to copy
Set wsI = wbI.Sheets("Orders by Customer")

Set wbO = Workbooks.Add

With wbO

Set wsO = wbO.Sheets("Sheet1")


Dim fname
fname = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="Excel Files (*.XLSX), *.XLSX", Title:="Save As")
If fname = False Then Exit Sub
ActiveWorkbook.SaveAs Filename:=fname


wsI.Range("=A:AA").Copy


wsO.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

wsO.Range("A1").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,227
Messages
6,123,739
Members
449,116
Latest member
alexlomt

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