Excel 2010 Macro to do the same task again and again - excel

I need to send Sales Report to my colleagues on the end of every week and I pull the same details from SAP (Stockwarehouse Russia). My question is, everytime I need to do the same steps again and again in Excel i.e. editing and deleting the same columns, applying filters, assigning the right description for the exact same fields, Movement Type etc. And it becomes very monotonous and pathetically time consuming.
So is there a way where I can record the steps I performed and store is somewhere on the HDD so that next time I can simply open Excel, run the program and report would be generated automatically?

What you will need to do is record a Macro
http://office.microsoft.com/en-gb/excel-help/create-or-delete-a-macro-HP010342374.aspx
http://www.dummies.com/how-to/content/how-to-record-a-macro-to-automate-tasks-in-excel-2.html
First 2 links in a Google search...

If you are using Excel 2013. I would higly recommend to use Microsoft Power Query AddIn (PQ). With PQ you can easily connect to SAP, than create some transformation with your data and save this as a "script". WHenever you open this worksheet you will have a fresh data. The adventage is that you don't need to use any piece of code and you can save your operation in few minutes.
Later if you will want to automate this operation you can write simple script (avaliable on the net) to refresh the worksheet and just add the code to send somewhere or if you have a SharePoint you can easily share with your worksheet with Power Query script into the SharePoint and everybody should have acces to your transormed data.
Please check: http://www.microsoft.com/en-us/powerBI/SAP.aspx#fbid=OjGdeZslbeu

Related

Is it possible to get data from a webpage in real-time to an excel file?

I would like to create an Excel Tool that would act as a Monitoring Tool for our agents on the floor.
Right now we don't have an exclusive WFM tool that would monitor and call out agents with their activities and productivity, the only thing we have is a dashboard to view all agents status and the durations of their status or calls. This is a web-based viewer of our dialer that would only shows agents with their current status but they won't trigger or notify if an agent is going over our set thresholds for their wrap up time, over breaks or lunch.
Currently, I have an existing excel file that would look up values from another sheet to populate the table with information that I need such as the name of agent, their current status and current duration of the call.
The another sheet I've mentioned above is a blank sheet where I would simply paste all the data from the webpage of our dialer. So basically I am just doing copy-paste method where I am selecting all the contents from this webpage which is our dialer and pasting it in on the blank excel sheet that I created and the table that I made will find all the values that I setup from that blank sheet.
I really don't have enough knowledge but I still tried Data>Get Data>From Web and I am not getting anything.
I tried pasting the web link, but I don't seem to pull up any data.
I know as I've mentioned, I don't really have enough knowledge and maybe I need some basics doing this method.
What I would like to happen is if there's a way to link a webpage, sync its data to an excel sheet and is it possible to make it real-time so that way I can have an improvised WFM Tool that would help me monitor our agents activities?
Thank you in advanced!
Getting data from the Internet through a standard mechanism (Data >Get Data > From Web) is not always successful. Excel can recognize tables on a web page, but not always in the way that the human eye recognizes them.
Actually, there are two options here:
write a macro that parses specifically those pages from which you are currently getting data manually (“…I am just doing copy-paste method…”).
prepare web pages so that data from them can be automatically downloaded via Data >Get Data>From Web via standard Excel functionality.
Both require programming specifically for your task.
For example, I could write a parser, but for this I need access to the web page from which you are copying and pasting.
Or the programmer who wrote the web page can create new pages with the same data, but in a format that Excel understands. But this programmer needs to specify exactly how to design web pages.

Filtering Excel via Power Automate and send Mail

I just got the permission to try out Power Automate.
We have only one thing running in Excel via VBA and should replace it with a new solution:
What does this Excel VBA:
Filtering Column A for each value in Column A
Copying the filtered content and create a new table with only this content
Take this new table and create a mail-draft for a recipient (mail adress is stored in another column)
Close table/Delete table
next record out of filter array based on Column A
I find many tutorials for Power Automate with iteration over arrays but i have no clue how to generate this initial array of possible criterias out of column A - the part with sending mail (and creating HTML tables within this mail) is shown often.
In addition to asking for access to Power Automate, also ask permission for Office Scripts. This allows you to record (and write) Office Script macro's which you can call from your Power Automate Flows.
The Script bit is needed to manipulate the Excel file and update the separate tables.
See this page for a starter on Office Scripts:
https://jkp-ads.com/Articles/Excel-office-script-basics.asp
And this one for some example scripts:
https://jkp-ads.com/Articles/Excel-office-script-examples.asp
It sounds like you should be looking into Office Scripts. You can find Microsoft's examples on Office Scripts under the Samples section here. And you can find the Stackoverflow forum on Office Scripts here if you have any specific questions.

Copy and paste Excel rows between two workbooks based on criteria from exported Access data

I have no previous experience in Access, VBA coding or in Excel macros prior to teaching myself the past month via these forums. Thank you forums and contributors. I have enjoyed my Access learnings so far, the challenge that it has provided and appreciate any help that I can get. As such, the code and methods that I have used to this point may well be convoluted and confusing. I will do my best to provide relevant details and accurate terminology.
I work in a lab and I am creating an Access Form for semi-automated reporting. Samples are received from clients and are logged into the Excel Table R&D Log. The worksheet is InProcess. Samples are sorted based on the site in which they originate and given a one or two letter site code (G, D, WH, etc.) and an ID "yy-000" in separate Excel columns (i.e. D 18-096). Samples may be submitted for multiple analyses (Metals, Water, Soil, etc.) and may even have multiple rows of reporting if multiple analytes are identified in the sample. There are several other columns, such as receipt date, reporting date, units, etc. Once samples are reported, I manually copy and paste them into the Archived worksheet, and delete the record and blank row from the InProcess worksheet. Since one sample may have multiple analyses and even more potential results, each record would be reported on a new Excel row (with the same D 18-096 ID number). Thus, there is not a single unique identifier or primary key for each sample in the current format. R&D Log is updated manually by lab technicians and the worksheet InProcess is a linked table in an Access Database.
The Access Database is using two combo boxes on a Form frmInProcess to filter a Query qryInProcess of the linked table. The combo boxes are filtering the report destination (one client may receive multiple site codes) and the analysis (reports are separated based on type of analysis). The Query is also filtering out blank results and blank dates, so only completed samples will appear on the filtered Form. I have generated VBA code to this point that will export the Form to a .pdf, save the file with unique filename, and open outlook to mail out the report. I have also managed to export the filtered Form frmInProcess to an Excel file Access Test (not the linked file).
What I would like to do now is to automate the transfer of completed test results from the Excel worksheet R&D Log: InProcess to R&D Log: Archived and delete the record from the InProcess worksheet. I am not sure if I can export the filtered Form into a linked Excel table, or if I must use a separate Excel file (or if it even matters for simplicity of code?). I would now like to read the exported filtered Form in Excel Access Test, lookup matching rows in R&D Log based on several criteria (site, ID, Analysis, Analyte, Report Date) and automate the transfer of records between R&D Log worksheets. End result being that Access generates reports for completed tests, and the records are removed from InProcess testing and transferred to Archived testing in Excel. I am guessing that I may need to close the Access application and perform this in Excel. Hope this is easy enough to follow.
Thank you.
In my experience, importing an Excel document into a temporary NEW (or totally empty) Access table is usually the easiest way to go. Then you do not have to worry about cell references like you do in Excel VBA. Even if the Excel document has old data in it with just a few new changes each time, importing it into a temporary Access table could be the simplest way to go, because then you can compare the data in this table with the data in another, permanent Access table and update the latter based on the former.
As far as the original Excel file, if you need to delete rows there, it might be quicker to export a new Excel file with just the data the old one is supposed to end up with, and then use VBA to delete (or - safer! - rename) the old file.
So the development process goes something like this:
Save import steps by first importing an Excel file via Access' ribbon options "External Data" (tab) ->"Excel" and when you finish, be sure to check the "Save import steps" box and note the name you give the "saved import" because you will need that in your VBA code.
In Access, write a function for deleting the table. The VBA code is:
Const cTable = "MyExcelTempTable"
If TableExists(cTable) Then
DoCmd.DeleteObject acTable, cTable
End If
Now you can test your delete function on the data you imported.
Write VBA code to import the same spreadsheet to create the same table:
Const cSavedImport = "Import-MyExcelTempTable"
' Import the Excel file
DoCmd.RunSavedImportExport cSavedImport
Write more VBA function(s) to check the imported table for bad data and then to copy it into the permanent table. You might be updating existing records or adding new ones. Either way, you could use Access queries or SQL to do this and run them from VBA.
Write a VBA function to rename the old Excel file. (You could use an InputBox if the Excel file name is different each time. I do this for importing Excel files, and I set a default value so I do not have to type as much.)
Write a VBA function to export the new version of the Excel file.
Make yourself a button on a form that, when clicked, runs a VBA function. Inside that function, run Steps 2 through 6, above.
I am not sure my answer exactly matches what you are trying to do, but hopefully you get enough of a picture of the workflow to figure out the details of what you need.

Updating a sharepoint list from Excel

I know this is a little backwards, but unfortunately this is what I have to do based on what I have to work with. Essentially we are getting data from one place, putting it into Excel and then running some pivot tables and then copying and pasting the results to Sharepoint. There is no way of getting the data into SharePoint from its initial source.
So here are the steps I have to do on a daily basis:
Go into 3 lists on sharepoint and delete the current data in there
Copy the data from each excel table and then paste it into the associated SharePoint list
Go into the Titles, etc part of SharePoint and update the file name to append the current date to it(ie change it from Data05032017 to Data 05042017)
I would like a way of automating this on a daily basis from Excel by simply pressing a button via VBA or if there is a way I can accomplish this wia linking somehow that would work too(not sure if its possible, I know you can link from SharePoint to Excel but unsure if you can go in the reverse direction).
So I first would like to know if this is possible and then if it is, how I go about doing it.

Using a JIRA saved filter with REST API and Excel

I have a report that I need to update in Excel many times a day using statistics from JIRA. If I can import these directly with code I would save a lot of time and effort.
Is it possible to use a saved JIRA filter in conjunction with the REST API function to import the results to Excel using a VBA macro?
This is a solution does not use REST API, but it may work for you. This is a workaround I am using so far and it works:
Run the Filter in Jira
Export the result list into an excel file using the Export CSV file with the option current field (to avoid having unnecessary fields) and with the right button of mouse select: Open in a new window
Now you will see the URL associated with your filter in a new window of your browser. Your filter is represented by a Filter ID, therefore the query will be always the same.
Go to excel and use the URL as a hyperlink
Every time you click on the hyperlink it will download the file from Jira. You need to have a Jira open sesion in your browser.
Create a VBA marco that click on the hyperlink for downloading the file.
Use Power Query for example for loading the file from the download folder location into a worksheet. Power Query is a new excel feature. Power Query is an ETL tool integrated into excel for loading files and processing them.
The steps 6-7 automates the process. Run the Marco for downloading the file and refresh the content of your worksheet from Data Connection. You can have an additional macro that refreshes the content of the worksheet. It refreshes all pivot tables and the file connection for reading the file.
Hint: Use excel Table for keeping the information updated automatically when additional information is loaded into the worksheet. If you use pivot tables for presenting the data, use as data source an excel table instead of excel range.
It minimizes a lot the manual effort.
Here you can find a solution that uses REST API, the author provides the source code, but it is more complicated. If you need something simple, my solution may work for you.

Resources