Saving file into a particular path into the current monthly folder

pscofe

New Member
Joined
Jan 24, 2020
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hi, I don't use VBA too often so it's very much record and come on here to check other threads! I've written one piece of code which works for what I need to do but now I want it to save into a file path and also in this months folder. What I have so far is:

Sub Formatfile()

Dim myDate As Date

myDate = Application.Max(Columns(1))
ActiveSheet.AutoFilterMode = False
Columns(1).AutoFilter Field:=1, Criteria1:="=" & Format(myDate, [A2].NumberFormat)
Worksheets("Call Tracking Report").Range("B:B,C:C,F:H,K:Q,T:U,AF:AG,AK:AN,AP:AQ").EntireColumn.Hidden = True
Selection.Copy
Range("AR1").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Comments"
Range("AR159").Select

End Sub

But I now need it to save down the file automatically (N:\PS\MO 2023\mgmt\investigations\2023). Within this folder i've created all monthly folders.
I've searched for some coding already but doesn't seem to work. Can anyone help? Thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Unfortunately you have not provided a detailed or clear enough description of your need. It sounds like you want to save a workbook with modifications done by the code that you showed?

First, I suggest adding some comments to your code so it is clear what each line of code is supposed to do.

VBA Code:
ActiveSheet.AutoFilterMode = False
Columns(1).AutoFilter Field:=1, Criteria1:="=" & Format(myDate, [A2].NumberFormat)
What is being filtered? Dates?

For example regarding
VBA Code:
Selection.Copy
What is selected? It SEEMS that it is the user's selection (selected cells)?

VBA Code:
Range("AR159").Select

Apparently, cell AR1 contains the word "Comments." Will comments be copied to another workbook?

VBA Code:
Range("AR159").Select

Why do you need to select this cell?

Ideally you provide a link to your workbook so someone willing to assist does not have to 1. recreate your workbook, 2. guess about what is in your workbook and 3. guess about what is needed. Use Box, Dropbox, 1Drive or Sharepoint.
 
Upvote 0

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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