Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-11-2019, 10:39 AM
BrianT BrianT is offline VBA Not working Windows 10 VBA Not working Office 2019
Novice
VBA Not working
 
Join Date: May 2019
Posts: 3
BrianT is on a distinguished road
Default VBA Not working

Hi



I have adapted this macro from various threads, however, it runs, but does not save as expected, only one sheet saves, not always the same sheet, and not always the correct filename

In short, 12 sheets in one workbook, run macro to move and save in folder on desktop, Filename is from cells A2, and C2 and L2 so one save file should be Acumen week 47 Week 48

A2 - Acumen, C2 Week 47, L2 Week 48

Any help, direction, would be appreciated

Regards

Brian



Code:
Dim part1 As String
Dim part2 As String
Dim part3 As String
'setting out the cells
part1 = Range("A2").Value
part2 = Range("C2").Value
part3 = Range("L2").Value


Dim strUser As String
    strUser = Environ("UserName")
    
Application.DisplayAlerts = False
    

Sheets("Acumen").Select
Sheets("Acumen").Move
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\" & strUser & "\Desktop\Forecast\" & part1 & " " & part2 & " " & part3 & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close



Sheets("Carlson").Select
Sheets("Carlson").Move
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\" & strUser & "\Desktop\Forecast\" & part1 & " " & part2 & " " & part3 & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close



Sheets("Gefco").Select
Sheets("Gefco").Move
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\" & strUser & "\Desktop\Forecast\" & part1 & " " & part2 & " " & part3 & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Etc etc

Last edited by Pecoflyer; 05-11-2019 at 11:42 PM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tasks Switch to Non-Working Days on Working Calendar danelloc Project 3 10-02-2017 12:38 PM
VBA Not working TOC Not Working Gary91 Word 3 01-21-2015 05:52 AM
VBA Not working working 4 10's, need help to set up rkirkland Project 1 12-19-2012 02:47 PM
GIF's stop working Kwarior PowerPoint 3 03-17-2010 09:59 PM
Spellchecker not working GR8Fandini Word 6 02-07-2010 01:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft