excel macro - new row copy - excel

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.

Related

Using an Excel Macro to identify and then filter out specific rows

I've been attempting to create a macro to grab certain rows in my excel sheet to no avail. Here's what I am looking at before.
I need to find the wording "Car result printed - (Car Name)"(shown under A2) and grab the content RIGHT below it and than paste that content to another column. As the second photo shows, F-150 was properly pasted into another column. Instead of a single instance this would have hundreds obviously.
I tried using a variety of macros, but kept getting stonewalled (probably because my lack of VBA). Any help would be appreciated!
Thank you all.

Copy Row to a position dependent on criteria

I've searched all over but have yet to find someone who has been able to asnwer this.
I'm in the process of trying to create a macro to streamline requesting days off, so to help modernize the payroll sheet while still allowing it to be compatible with the legacy system.
I want to have this sheet be the input:
And then the macro (activated from a button click)
would copy that data, find the associated employee, then paste to fit with the legacy system as shown below:
So the macro would match the respective employee of each entry, and paste the respective entry to the next entry in the log of the employee. Any idea of how to go about this?
I am completely lost and not sure where to start.
Maybe you could show your code and ask a concrete question about it? Because there's no problem in VBA to copy-paste any Range of Cells (or it's values, or it's formats etc.) with any logical conditions you need. MSDN has a clear example: https://learn.microsoft.com/ru-ru/office/vba/api/excel.range.copy

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.

vba excel: How to fill in two cells in a row with text

I need to make a header in my excel sheet using VBA. Seems pretty simple, but when I do this
Worksheets("New_Students").Range("A1").Value = "studentID"
Worksheets("New_Students").Range("B1").Value = "ISUID"
only the first line works and not the second one. What am I forgetting?
Try this:
Inside the excel application go to the developer tab on the ribbon and click record macro.
Type the values into the two cells manually.
Click stop recording and view the macro it created.
This would show you VBA code that will work and you can compare it to what you have in order to trouble shoot.
This is called recording a macro and can be very helpful in solving problems. In fact I would suggest doing so almost every time before asking a question here.

Create a new sheet for each row

In an Excel sheet, I have roughly 30 rows x 100 columns of data. Each row represents a different "client". For each client, I've create a summary sheet that is emailed to them and that also contains all the information from my main sheet
Is there a way for Excel to create a new sheet based on some template sheet when I add a new row to my main sheet and fill it with the appropriate data?
I will give you my opinion about your need, the way I see it, at least. It is not a "ready to use" solution, however, only some ideas about the way to do that.
From what I know, there is no way to track insertion of a row in Excel. So you would require a VBA function to be activated on a button, for example. Actually, there is, see Lunatik's answer.
This function would loop over all rows in your main sheet, and create a new sheet when necessary (you would need preferably a unique id for each client, it could be a simple index on the main sheet, depending on the line).
You would create at first your template sheet, with a specific name, and eventually hide it (to not have it in the visible tabs). When I say that the function would create, it would in fact copy this template sheet and give it a unique name (the id I mentioned earlier). You can find ways to copy sheets at this link.
A second operation to do, would be to put data from the row in the main sheet, to the template sheet (if I understood correctly your requirement), which is not really complicated to do in VBA.
If you need this to happen automatically on the addition of a row then you would need to use the Worksheet_Change event to capture the completion of a new row.
This would then generate a new workbook from the template, copy across the necessary ranges then save the new file somewhere, much as Gnoupi says
All this is relatively trivial with VBA, but unfortunately if you aren't familiar with VBA then isn't a simple case of "Do X then do Y in Excel" so I think you may struggle, even with sample code posted here.
Even if I created a dummy model that did what you require, functionally at least, then customising it to your particular needs may difficult if you are not used to working with Excel programmatically.
Edit
I've created a very simple demonstration of how this could work: http://drop.io/4clxof3 - note this example doesn't include the event handling for adding a new row, has almost no validation or error handling and makes sweeping assumptions about almost everything(!)
If you feel comfortable using this a basis for developing your own solution then great. If the whole VBA thing is foreign to you then it may be time to call in reinforcements :)
i was wondering if it was possible with no error catching. Simply just have a VBA code that takes each row of the Excel Document - Creates a file for each row and then at the end combines the total files in a folder into one?
I know sounds weird.. but is this possible?

Resources