I have been poking around here for years before i registered, always finding the answers that i need for excel and vba without having to ask. However i have a simple(?) question i can't seem to find the answer to -
I am making a timecard that has a 'save' macro button that when the user clicks, it will name the sheet and the file the same value (from a cell on the sheet) and save it in the same folder as the timecard template. (if you need it, the name will be employee code + weekending date) also, my excel knowledge is pretty good, but with VBA, i seem to know about enough to get myself into trouble...
I have a Workbook that already has a macro in it that will generate multiple sheets based on certain criteria.
For each of these newly generated sheets (numbered 1-6 in the attached example), I need to be able save each of them to a PDF file based on a unique name contained in a certain cell (in this case, each named is referenced in cell Q1 of each sheet). As such, I should end up with 6 pdfs based on the attached sample files.
The PDFs would ideally need to be landscaped and should be just 1 page per sheet.
In my attached sample workbook, you'll notice that I have a "PracticePrint" macro that doesn't quite get the job done. One other criteria involves not printing any sheet with the characters "1010" in it (my PracticePrint macro is setup to do that, but it fails to do much else).
Actually i've downloaded Tracking report of my SPO and this report is on 4-5 csv files (1 file per week). I have to gather data from these 4 files into one Worksheet. I have to do this with command button on my worksheet; with Open file dialogue box (i want to locate the csv files).
CSV files are something like that (I need only first 4 columns):
and my Worksheet is like that (With a command Button):
I want to import first 3 columns of csv file on first 3 columns on my worksheet; leave 2 columns blank and then import the 4th column... now for example i have done importing data from 1st csv file and the data is on 50 rows.. i click the command button again, locate the 2nd csv file.. do the same thing (import 1st 3 columns, 2 blank, then 4th) --from 51st Row-- and so on...
I have a macro which successully saves a worksheet as new file to another file path....(below)...but I can't figure out how to close this new file and return to the original file...
Dim myPath As String, fName As String myPath = Sheets("Date").Range("C8").Text fName = Sheets("Date").Range("C9").Text Sheets("Sage CSV File").Copy With ActiveWorkbook .SaveAs Filename:=myPath & fName End With'
I want to create a macro that will select all the worksheets (names and quantity will vary) and saves the file as the current file's name but in PDF. Since I only know how to record a macro it specifies the worksheet names but I need it for various workbooks. The name will vary plus the number of tabs can go anywhere from 3 to 40.
I have certain excel file that i want to be able to write a macro in order for it to extract certain information from certain cells on different sheet. In other words, i want cell A2 from each of the three different worksheet i have under different files. And have those data automatically update a master excel or access file whichever might be easier.
I have attached the file I am working on. I am attempting to create a link to an external file based on the value of cells in column A. Then I would like to simply copy the formula down, lets say in Column B, the rows and as I do the external file reference will change depending on the value within the cell in Column A. I hope that I am making sense.
I am using Windows Vista with Excel 2007. The files will all be within the same file folder, however, there are hundereds of files so I won't be able to open them all for the indirect to work.
I have numerous spreadsheets that I need to open and unhide a sheet, that has XML data stored in cell A1. What I need to do is copy that data in cell A1 and paste it into a text document and save that as an XML file saved as the XLS workbook name with a date stamp.
I'm running into many issues, the main issue is the saving as current file name, and the formatting of the text/XML file.
Here is my current code, which doesn't reference the current file name and is just very generic. Once I get the saving as file-name correct and the formatting of the xml file correct, I will work on it a bit more.
Code: Sub Test() Dim Rng As Range Dim wb As Workbook Set Rng = Range("A1:A2") Set wb = Workbooks.Add With wb Rng.Copy
I want to be able to run the following lines of code to edit all xy-scatter plots on worksheet that is currently open by clicking and running a .VBS file. This is the code that works in excel in my macro. I'm having trouble getting the .VBS file to execute and run correctly. I realize I don't need the dim statements for the .VBS file, and have been able to get it to run without errors, but it doesn't edit the chart.
Code: Sub ChartLineWidth() Dim c As Chart Dim s As Series For Each co In ActiveSheet.ChartObjects() Set c = co.Chart For Each s In c.SeriesCollection s.Format.Line.Weight = 1 Next s Next co End Sub
As a newbie to macros I am having trouble trying to save a worksheet to CSV file. The macro worked to .txt but when I change it to .xlCSV it comes up with runtime 1004 error, method 'save as' of object '_workbook' failed.
Sub Export7400_setup_Click() ' ' Exportsub Macro ' Dim sPath As String Dim FName As String FName = Range("rng7400Filename") sPath = Range("strWorksheetPath")
I have about 50 CSV files in a directory named C:POSTAL. Each file has about 4000 records with three fields, Name, Address, Phonenumber. I would like to find some way to combine them into one large CSV file named ALLRECS.CSV so that other parts of the program can open that file and search it by Phonenumber, so I can display the Name and address on the screen. Obviously it is too large for Excel, at the moment. In old DOS you were able to use
copy *.CSV ALL.CSV"
to combine all the CSV files into one. Every now and then I want to delete the old ALLRECS.CSV file and replace it with a new one, as we update the phone numbers in the individual 50 files. For example I would like to use a button so the user can simply update whenever they wish by clicking on it, deleting the old and adding the new.
I have a workbook which utilizes 2 worksheets to fill a third. I would like a macro to be able to save JUST that worksheet, and not the other two. I thought there was a checkbox allowing you to "save selected" only, but I'm either dreaming, or it was in a previous version of Excel (I know use Excel 2000).
i'm using the following code to compress a worksheet, but i get an error message that i would like to surpress...
'zip On Error Resume Next Dim FileNameZip, FolderName Dim strDate As String, DefPath As String Dim oApp As Object DefPath = "c: empsalesmanMDBed" If Right(DefPath, 1) <> "" Then DefPath = DefPath & "" End If FolderName = "c: empsalesmanMDBed" '<< Change..................
So I am trying to design a workbook that has two worksheets... one with instructions and a button for users to click to "Save as .CSV File", another for the data that will go into that CSV file.
Here are the Macro requirements: 1. The user will be prompted for the File & Location to save the .CSV file 2. If they click 'Cancel', no changes will be made (and unlike my current code, it won't ask them to debug). 3. Confirmation of the filename is not necessary even though it's currently included in my Macro 4. The file will automatically "reopen" so that they only see the new .CSV file without the original Instruction tab.
I keep track of returns for my company and I am pulling a CSV file with all of the information on it.
I want to be able to format the info and create new columns for info I enter in to the sheet, and be able to import the updated CSV file into my already formatted sheet.
The part that I am wondering about is, after I import my first CSV file(sheet1) do I need to create another sheet(sheet2) and format sheet2 and have it pull the info from sheet1, then when I update workbook1 the data will update in sheet2?
Or, is there a way to just import the new data a single formatted sheet that I created from the old data and have it just add the new data without messing up any of my formatting?
I have 2 workbooks, and want to copy an entire worksheet from 1 to the other workbook.
In the closed workbook, I want to copy "Sheet1", and paste that into the open workbook on worksheet "Original File". What code do I need to complete this?
Dim fexport1 As String ' variables for the exported file Dim fexport2 As String Dim wb1 As String 'variables to change between the opened workbooks Dim wb2 As String strTemp = "Please Choose The Exported File" MsgBox strTemp fexport1 = Application.GetOpenFilename("Excel Files (*.xls), *.xls)") If InStr(fexport1, "False") = 0 Then Workbooks.Open fexport1 wb1 = ActiveWorkbook.Name
Else strTemp = "Operation Canceled" End If
The problem is that Crystal Reports generates the file with an invalid worksheet name (it contains a backslash) and I do not have access to modify the Crystal Report. Althought the file can be automatically repaired by Excel when manually opened, the macro chokes and the "Application.DisplayAlerts = False" does not fix it. The only solution I can think of is renaming the worksheet without opening the file.
I have a macro to loop through the files in a folder. The macro will then open up the files and copy over to a new workbook.
As I want to rename the worksheets created in the new workbook as part of the file name. Any idea how to extract the file name out and stored in a string?
Currently it will be named after the Cell A1 in the opened file. However I would like to rename as below.
Example, the file name : 030309_Mary Sales.xls, Worksheet Name to Create : Mary Sales. File name : 030309_John King, Worksheet Name : John King
(in the code, 030309 taken from my menu sheet,D4 is the keyword , to search in files containing D4, where D3 is the directory to look in)
Sub RunCodeOnAllXLSFiles()
Dim lCount As Long Dim wbResults As Workbook Dim wbCodeBook As Workbook
I am using excel 2007 and I’m trying to open a file folder from a worksheet using a control button. They are both in same file folder. I’ve have tried Workbooks.Open Filename:=ThisWorkbook.Path & "Report"
I also tried to record a macro but would not record going to file folder.
I have a workbook with multiple worksheets. I want to save only a specific worksheet to a new file name and have only the values in the work sheet saved. This particular worksheet references values on another worksheet which uses VLOOKUP to pull data from yet another worksheet. I also want to automatically name the file using a pre-determined name located in a cell reference and save it to a specific location on the LAN drive.
I have an excel file that has quite a few buttons with macros attached and combo boxes. On one computer it runs perfectly normally, however on another, when the file opens all the comboxes and buttons with macros attached have been stripped from the file.