Excel - Automatically Generate Reverse Sheet - vba

Am trying to automate a workflow . Basically its a Bus schedule timetable .
Say , I have a worksheet with multiple columns And a Set Formula to calculate Reach Time Between Various Stops .
I want to calculate another sheet with the Return Journey Timings .
Source Sheet :
Automatically Generate Reverse Sheet with Modified Formula:
The New Reverse Sheet Should Copy the columns in the Reverse Order . And modify the original formula using the time.
Target :
Create a Sheet where I enter a start Time , the other times should be automatically populated . I have the start times for the sources
Idea is - once I populate One way route with a formula , create a new sheet with return journey details and give an option to enter start time from the return source .
Could this be done in Excel Macros or any faster approach ?
Tried the excel record option but that takes the hard coded column names. Its not dynamic as to if i have a new route with different number of stops , i want it to generate the reverse order sheet based on original
Appreciate some help . Thanks !

I have not tested in Excel, but this uses functions that are shared between Sheets and Excel, so this should work. You can jazz this up to use sheet references, but I kept it simple.
Assume your forward schedule sits in rows 10 and 11, starting in column A. In A13 enter (columns matching matters here)=iferror(offset($A10,0,counta(10:10)-COLUMN()),"") dragging it right as far as you can imagine stops going as well as down one row (for cosmetics you will hide this row (14 in mine) later). Then one row down from that you can enter (and mess around with) whatever time you want in the first column. In column B next to it, place =A15+A14-B14, dragging that right as far as the last stop. These times will be right and will adjust as you change the contents of the first column or the rows on which things are based. You will get nonsense if you drag things further right. (probably there is a way to fix that)

Related

Need script to automate process

We keep our orders & production in Excel. An order workbook looks something like this:
Main Order XXXX
Cabinet
Solid Surface
Diewall
Custom
Metal
Finishing
Moulding
Adaptable
On our Main Order tab, we have a table with all the items on the order. What I need, is a way to automate copying certain rows to certain sheets. We have column on the Main Order that can be used to state which sheet that row needs to go to. Also worth noting, we sometimes have to ADD new sheets if we need more items that need to go on 2 separate Custom tabs for example (but this could apply to any of the sheet names other than Main Order). We do that by copying the applicable sheet and renaming it 'Custom1', 'Custom2'. It's the same format for each sheet - a number after the name of the sheet, no space. Right now, we are doing this all manually and it's very time consuming. Would it be possible to make the script create the new sheet based on what is in the Main Order? Meaning, if we put 'Custom1' in the Main Order table, can the script create the sheet called 'Custom1', copying the 'Custom' sheet and then adding the rows from the Main Order?
I'm not sure if it matters, but the Main Order sheet table starts at Row 18 and is variable in length depending on the order. There's another table below that, but that doesn't need to be copied anywhere. The tables where that rows need to be copied on the other sheets all start at Row 13 (that's the header row) and we can add however many columns we need.
I will admit I'm very new to scripts and VBA, but I have a very basic understanding (I think anyway). I feel like what I'm looking for should be possible, I just don't know enough to figure it out on my own at this point.
I found a script that copies rows to a table, but I need it to be more dynamic. I don't want to have to create a script for each sheet, especially since new sheets can be created as stated above. Below is the script I already have, and I confirmed it worked for the 1 sheet ('Adaptable'). I'm hoping someone can help me make this more 'generic' if that makes sense? So in our Main Order, I want to be able to put in a column the sheet name that the row needs to be copied to and then have it automatically copied, or if the user needs to click 'Run Script' or whatever, that would still be much easier and faster than what we're currently doing.

Text Manipulation nestled within a Query (Or ArrayFormula) (Google Sheets)

I'm trying to Query some data in my spreadsheet, returning a manufacturer based on product code. We code our products with a three digit suffix that corresponds to different customers. I know the codes but people viewing the sheet may not.
Right now, I'm trying to split the suffix from the product and perform the wuery in the same formula.
I can do this in two steps, splitting the suffix from the code and querying just the suffix, but I want to know if I can do this all in one code. My current formula returns the data I want but it does not fill the entire range of the sheet. I would rather have this happen automatically as the workbook will be dynamic.
My current formula is:
=QUERY(CxSeries,"select B where C CONTAINS '"&right(Code,3)&"' ")
https://docs.google.com/spreadsheets/d/190kom4q0XOJP4UdLTJpZf5tuJCQTflcuokRp_FJ4pBc/edit?usp=sharing
I'm not sure if query is the right way to go about this, but I'd prefer to stick to that (just because i honestly can't wrap my head around ArrayForumlas).
Thank you,
Clear all formulas you have in column C and enter in C7
=ArrayFormula(vlookup(regexextract(D7:D16,"-(\d+)$")+0, {Sheet5!C6:C,Sheet5!B6:B}, 2, 0))

Splitting data between worksheets depending on status of Column A

I have been asked to create a database of volunteers in Excel. The main worksheet (called Data) holds all the information – names, addresses, numbers, reference checks, placements, supervisors, etc. What I am trying to achieve is for the relevant information to be moved from one worksheet to another when the status of the person changes.
There would be 5 categories which the volunteers would fall under (column A labelled ‘Status’)
PROCESSING
ACTIVE
ON HOLD
BARRED
STOPPED/RETIRED
What I want to get is a live database so the information would appear on a relevant worksheet whenever the status on the main spreadsheet changes , but I only want some information to show depending on the category…
Each Worksheet would contain columns A-F from the ‘Data’ worksheet and in addition:
Processing would contain columns X-AE
Active: AF-AW
On Hold: AZ-BC
Barred: AX-AY
Stopped/Retired:- BD-BH
I have searched and searched again but I know nothing about Macros (and my IT department is unable to help) So my question is – is this doable and if so is anyone able to help me?
I hope I am making sense and if not I can email across the dummy database with some made up names to show what it is I am trying to create
You can do this using array formulae. This link shows a simple example which provides the basic formula (explained in detail in the linked article)
=INDEX(range,SMALL(IF(col=value,ROW(range)),ROW(1:1)),COLUMN(A2))
Where range is the range of all your data from your main worksheet and value is the value you want to screen for (this changes for each of your sheets) and col is the column on your main sheet that you want to check the values of. Note it is an array forumla so you have to press control+shift+enter after typing in the formula as explained at the bottom of the link.
You will notice that I have changed the formula to say COLUMN(A2) instead of 2. This is so that you can drag the formula across the columns as well as down the rows. You might need to make this COLUMN(A2)-x where x is an offset because your data don't start in column A.
Note that the same applies for the ROW(1:1) part, if your range doesn't start in row 1 then you will need to offset this by some value as well (i.e. something like ROW(1:1)-y)

Autofill Custom List

I am trying to code a schedule generator in Excel using formulas or VBA that can automatically fill in the correct cells with data from a custom list (it can be stored anywhere - another spreadsheet, somewhere in the same sheet). Does anyone know an easy way to do this using VBA/Excel formulas or some other method (maybe even a better program to do it in)?
A user should type the start date in a cell and then it automatically fills in the same data into the weekdays, skipping weekends and holidays, which are also user inputted somewhere in a spreadsheet.
This picture explains what I am trying to accomplish:
There would be a place to input a new class and start date and the rest would auto fill. The custom list would be the titles (i.e. Database Basics, Tables, Primary Keys, Foreign Keys and so on)
The top two rows are date and day of week (that part is easy) but then give a start date fill in the list (until you reach the end of the list) in the weekdays but do not fill in weekends or user chosen holidays. Ideally this would work for every row. So if I have multiple start dates then maybe rows 3,4,5 would have different schedules but I can see where they coincide and do not based on this simple view.
This is a description of a technique that you may adapt for your use. Say we want to auto-fill dates (working days) in row #1 based on a staring date in cell A1.
Leave A1 empty. Format the cells in row #1 as Date.
In B1 enter:
=IF(A1="","",WORKDAY(A1,1))
and copy across. Now when a date is entered in A1, the rest of row #1 will follow suit.

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: