Power Automate to copy rows between sheets in excel - excel

I have been trying for days to write an office script to copy rows between sheets based on a value selected in a drop-down list, then delete said row. I have tried many iterations of code but as I’m new to scripts its been unsuccessful every time.
However I was wondering if I needed a script period and could the process be done using Power Automate? I was intending on using it to do the trigger event in any case had the script been successful
Thanks
When I wrote the script it was supposed to copy the row from master sheet paste in the complete sheet to the last row. Delete said row from master.All triggered by a value selected in drop down list.
The scripts had varying outputs but none as intended.

Related

Automate tasks to access data within excel files

I am between beginner and intermediate user of excel with no coding background. Not sure if I need to use power query or not for this. If not, any VBA code to accomplish the same would be great.
I want to automate the consolidation of data and processing it for 10 production lines.
Each production line has its own folder on the drive.
Within each line's folder, there is a monthly folder example - March, April etc.
Within each Monthly folder there is a day folder - May 1, May 2 , May 3, etc.
Within each day there are 3 excel files - Shift 1, Shift 2 and Shift 3.
Data for each shift for 10 different lines is collected and manually entered into its specific shift excel file by production operators.
There is a master file located elsewhere on the drive which processes data from these lines but currently it has to be manually transferred to the master file - which is a pain and super time consuming.
The master file contains 2 worksheets for each production line. I would like to copy and paste specific range of cells (H9:R24) from the shift production line files into specific worksheets within the master file specifically made for those production lines.
The column before the cell ranges where I would like to paste the data (in the master file) contains dates and hence I am hoping that the code/query will help me paste via matching the date from within the shift excel file.
Each shift excel file is exactly the same in terms of naming of columns, formatting, formulas etc.
Once pasted into the specific worksheet within the master file, cells in another worksheet (within the master file) use these numbers to process these via formulas and more numbers are generated such as waste % etc. which will be automatically plotted on different graphs.
I would like to super automate this process with a click of the button in the master file to access the data within those files, copy and paste into specific cells in specific worksheets within the master file and process data according to specified formula (already within the cell) to ultimately give processed numbers and graphs for each line for the previous day.
This needs to be repeated for 30 files - 3 files each for each day for 10 lines - every single day first thing in the morning.
Not sure if I need to use power query or not for this. If not, any VBA code to accomplish the same would be great.
Requesting you kindest help.
Thank you !
Power Query is the best tool for this task. You should not need any VBA.
Start with Get Data / From Folder and point it at your root folder for all production lines. It will browse all the subfolders and give you a list of files, with the path for each, as a table.
As long as the individual file content is consistent, you can then hit Combine to generate a Function Query that will repeat for each file. You'll need to build your transformation logic in that query.
You can build queries by "Reference" to this main query, e.g. transforming the data for a specific chart requirement.
The "click of a button" will be on Excel's standard Refresh button - that will re-run all the queries and refresh their output tables. That can be automated with a one-line VBA macro or using the Power Update add-on.

Exporting data to Excel sheet without writing column names in SSIS

I have this problem. I have to create an Excel 2007 file dynamically. To do so, I have an Excel connection with the "First Row Are Column Names" check uncheked. Then I created a SQL Task with that Excel connection and the following SQL Statement:
CREATE TABLE `MySheet` (`MyColumn` LongText)
And then I have a Data Flow Task that fills the sheet with a single-column stream of data.
The problem is that even though I unchecked the "First Row Are Column Names" check, the exporting still writes "MyColumn" in the first row. I need to be able to export the data from the first row onward, without any other thing being written on it.
This is a problem because there's the possibility that the Excel file must be overwritten by the SSIS package on a different run. Since we don't have deletion permits in the folder where the file is created, I need to delete the contents of the sheet from the previous run. I manage to do this using a SQL Task and the Excel connection with the statement:
DROP TABLE [MySheet]
This manages to erase every row without deleting the sheet. But, since this task is followed by the Data Flow Task instead of the sheet creation task (because the sheet is still there), when the Data Flow Task fills the rows again, it leaves the first row empty. It doesn't re-write the column name.
This difference is what I'm trying to avoid.
Is there any way to avoid this?
Thanks
Short and sweet answer is no. Not possible. It will always have to use something to make it distinct. What you can do is, use a small poweshell script to open the excel file, run a small macro to delete that first row and then save it and close it. There are a lot of powershell scripts that can help you with this.

Move columns A to E to new sheet and repeat. Excel

I have slightly different data but same format in one excel sheet.
Each data set is 5 columns. The first data set is column A-E, the second data set is column F-J, all the way through to DID-DIH
What I would like to do is to extract these to either their individual sheets or individual workbooks
Is this possible? Perhaps using VBA code?
Sorry I am an amateur trying analyse a massive data set
A good way to get started would be to hit the record macro button and copy the first columns manually. Then stop the recording and look in the VBA editor at the code produced. Wrap this in a loop and make the necessary changes to move columns etc. Have a go and post the code if you get stuck.

excel macro - new row copy

Been searching around for a while now without any answer.
I'm creating an automatic schedule that calculates working hours and so forth for my employees.
Instead of creating new rows at the bottom of the table manually, putting in all the funktions and style the cells with specific formats I want a macro to do this.
I have created a macro but, the problem is that everytime it is executed, it starts of course from the place where I created it in the first place.
So, the macro should somehow search for the last place in the table. Copy the two last and create new ones including the if-statements, cell format and styling.
The second macro I need to create is a toggle function where the macro searches for the rows that containts the working hour (underneath the times) and hides or unhides the rows. Is that possible?
I really hope that someone can help me! Thanks!
/Martin
Screenshot: http://www.martinhult.se/screenshot.jpg
Would be better if you can share your first macro (which I believe is recorded?).
But essentially you want to use something like "activesheet.usedrange.rows.count" to see how many rows have already been used and then start at used rows + 1.

Using VBA macro to insert functions VS only using macro

In short, I would either:
Create a macro that runs every time a cell within a certain range is changed, and then writing out the result based on those cells.
-OR-
Create a macro to automatically insert functions that would do the same thing
Things to consider are that this would need to work on multiple tables of varying length without need to manually change anything, and that the results of individual sheets would need to be also displayed in summary on another page.
Which would be more desirable/more efficient/easier to implement?
The subject data entails testing procedures. Sheets contain testing criteria and a column containing PASS/FAIL results. I need to tabulate these. The start of the table and the end of the table are at different rows and are subject to changing.
Without seeing your actual problem I would definitely go for the first option. Having many formulas inserted into cells dynamically I think would be a pain.
Use the Worksheet_Change event and test whether the cell changed is one of your target range, then perform whichever action is required.

Resources