Auto creating a task-manager - vba

I would like to create a task manager using macros, but I have no idea how i can do it with the sheets i am using atm.
I made a sheet which shows
- Who wil execute the task
- What is the urgence of the task
- Where should it be done
- On what construction-element the task should be done
- What is the task that should be done
- A empty-line to place notes.
In excel my sheet wil look like:
The A1 line wil be headers.
A B C D E F
A1 Executer Urgence Location Construction-Element Quantity Activity
A2 Housemaster 1 Livingroom Door 2meter Replace
A3 Technical Deperartment 4 Kitchen Ceiling 0,5meter Fix
A4 External company 2 Bathroom Floor 1 meter Repair
I would like excel to auto-create new tabs for every executer. So each executer get a tab with all task he or she should do.
Excuse me for my poor english, its not my native language.
Thanks in advance!

Copy the sheet for each executer and give them the executers name. Then go thru each of that new sheets and delete all rows where the executer name is different from the sheet name. This can all be done via VBA so that you have a fully automated solution on the end.
But that's not been done in one or two rows so you can not expect that we provide the complete code for that ;-). Let us know when you have a specific problem on one of the steps.

Related

Excel - Call function from other cell

First of all I would like to tell you that I have just basics with VBA or Visual Basic. So probably there will be better solution in VBA, but I was unable to find a way. That's why that my attempt is so crude. Also my english can be somewhat broken sometimes. I'm sorry for that.
Below you can find screenshots from my excel sheet. You can notice functions are in czech language. You can find translation below.
Screenshot with actual results:
Screenshot with actual functions:
Translated functions:
AA =COUNTIFS(A:A;X2;D:D;D129)
AB =IF(AA129=1;CELL("address";INDEX(D:D;MATCH(D129;D:D;0)));"NULL")
AC =IF(AA129=1;REPLACE(AB129;2;1;"M");"NULL")
AD =IF(AA129=1;CONCATENATE("=IF(";"""";M129;"""";"=";AC129;";1;0)");"NULL")
AF =ISNUMBER(AE129)
AG =IF(AF129=TRUE;CONCATENATE(AE129);0)
Description:
Every day someone downloads .csv files from JIRA and uploads it to excel. That csv contains test cases. Column X has the date when this csv was uploaded, Column D has the ID of the test case. Column M has the date of the last change on that test case.
Functions description:
AA: It searches if there is the same test case in previous day. If yes, then result is 1. If no, Result is 0.
AB: Locates the exact cell location of the same test case from previous day.
AC: Serves for translation from ID column (D) to last change column (M).
AD: Composes translated information from AC, so it will create a function, which I would like to use further. That function will compare last change date with the test case from previous day and current day. Result should be 1 or 0 depending on if there was any change.
AF: Checks if AE is number (AE should be the column where I would like to run
that function from AD).
AG: If AF is true, then it copies value from AE. Else it's 0
Problem is:
I can't find a way to trick excel to take the text from AD and use it as function in another cell. Tried to program it in VBA, but failed.
What I need:
Translate result from AD from text to function and then run it in AE.
If there is a more efficient way to program this, I am open to suggestions. But I would like to have an answer for my question as well. I want to know if it's possible because I will make more complicated cases later while I learn to work with VBA.
Thanks for the response.

Excel copy all values from one main sheet to various other sheets if they are a certain colour

Would really appreciate a solution to the below:
I am looking to have 8 sheets.
Main sheet that has all jobs, these are all currently sorted into the following colours :
Red - live
Green - invoiced/complete
Blue - quoted
Black - enquiry
Grey - dead/ lost
Purple - work in progress
Yellow - Retention
what i would like to do is keep the main sheet and have a sheet for each of the above. when the text becomes red for example i would like it to be transfered to the live sheet and vica versa for the rest. this should be in a macro
can anyone help?
Many thanks,
You say "when the text becomes red " so possibly this is a conditional format?
In any case, what you need to do is to attach code to the main sheet's Calculate event . This code should do the following
look at the activecell's color element that you mean (font, background, conditional formating, etc)
Based on that color, copy the entire row to the appropriate sheet
(Can you assume the sheets already exist?)
You will probably need a Select Case Statement. I would declare a worksheet variable and then SET it to the appropriate sheet in the select
and then
Activecell.entirerow.copy ws.cells(ws.rows.count,1).end(xlup).offset(1,0)
will copy the row to the desired sheet at the bottom of any existing rows.
Have a try and come back with code if you get stuck
EDIT: Sorry I missed the "click a button" part. You can ignore the bit about the sheets calculate event - just attach your code to the button. The only thing to worry about then is that you will need to run through all the used rows of the sheet, since there might be more than one coloured row when you click on the button.

Create new column in Excel based on previous column data

Just a disclaimer: I have limited experience with Excel and sql... I'm basically a noob, so bear with me.
I have a big Excel spreadsheet that is sent to me daily that I would like to manipulate.
I would like to add a couple columns that create values based on their respective rows.
ID Color Brand Indicator
1 Green Vizio TRUE
2 Yellow Samsung FALSE
3 Blue Samsung TRUE
4 Red Sony FALSE
5 Orange Vizio TRUE
In the example above, the Indicator column is the one that I'd like to be created based on the values in the previous columns. The Indicator should be true if Brand has the word Vizio in it, OR if the color is Blue. I mention it has to have the word vizio in it because there are cases where it won't be simply "vizio", but maybe "vizio tv".
I would like to automate this process as much as possible, so do you think it would be best to use an Excel VBA macro or SQL for this?
Any help would be much appreciated, thank you.
You can use the following Excel macro.
Public Sub AddIndicators()
Const INDICATOR_1_COLUMN = 4
Const INDICATOR_1_FORMULA = "=OR(IFERROR(SEARCH(""vizio"",C2),0),(B2=""blue""))"
[a2:index(a:a,counta(a:a))].Offset(, INDICATOR_1_COLUMN - 1) = INDICATOR_1_FORMULA
End Sub
This can easily be expanded for additional indicator columns.
To have this macro available to run whenever you receive your daily worksbooks (and without the need to add the macro to the incoming workbook) simply add this macro to your Personal Workbook.
After that is done, just make sure your daily workbook is open and on the sheet where you want the indicators before executing the macro.
If perchance you do not wish for the formulas to remain in the indicator column, you can use this version of the macro instead:
Public Sub AddIndicators()
Const INDICATOR_1_COLUMN = 4
Const INDICATOR_1_FORMULA = "=OR(IFERROR(SEARCH(""vizio"",C2),0),(B2=""blue""))"
With [a2:index(a:a,counta(a:a))].Offset(, INDICATOR_1_COLUMN - 1)
.Formula = INDICATOR_1_FORMULA
.Value = .Value
End With
End Sub
Your requirement is very simple. You don't have to go for VBscript, macros etc. It can be simply done with excel functions.
=OR(ISNUMBER(SEARCH("blue",B2)),(ISNUMBER(SEARCH("vizio",C2))))
Assumption: Color is in column B and Brand is in column c and data starts from row 2. First row is for headers.

VBA Macro 'Moving" Graphics / Dynamic Graphs

Basically, the problem here is that I have a macro which changes the number of a specific cell and by doing that I change the numbers from three columns and when those numbers are changed my graphic starts to 'move'.
To be more specific, I have this graphic:
When I click on the button I have, the lines starts to move, and it looks like a mouth opening and closing.
The blue line corresponds to the first and second column values, whereas the red line is changed accordingly to the first and third column values:
Cell(B2) contains the number generated by this code:
Sub OpenMouth()
For i = 1 To 20
Worksheets("Mouth").Cells(2, 2).Value = 0.1 + 2 * i / 20
Calculate
For j = 1 To 5000000
Next j
Next i
End Sub
What I need to do is to prepare something similar: A graphic that by changing the numbers I have in columns A, B and C, it starts to move. The columns A, B and C will be changed by doing a simple loop in VBA, this loop will change one value, and the three columns will have a formula linked to this value, so they will have their values changed.
I've seen some really cool graphics, a ball rolling, a wheel moving, but I really don't have a clue of how to do this, I don't know how to do it.
Does anyone have an idea? Can anyone help me build a different graphic with a similar idea (of an object moving)?
This is another example, using the same logic:
Frankly, I would suggest rethinking your approach of creating a custom & complex animation in Excel. Excel just isn't the right tool for this.
I would use Javascript and embed a Internet Explorer control into Excel with the animation. The solution would work as follows:
Press a button in Excel
A VBA macro executes the animation by loading the Microsoft Web Browser control with a custom HTML file with your animation in Javascript. The animation is show in the MS Web Browser Control.
Drawing in Javascript
Here a simple tutorial:
http://www.w3schools.com/html/html5_canvas.asp
Test your drawings here:
http://www.codecademy.com/courses/web-beginner-en-SWM11/0/1
Microsoft Web Browser Control
https://msdn.microsoft.com/en-us/library/aa752040(v=vs.85).aspx

Newbie to VBA, Need a tricky function

Thanks in advance for any help...
(This is for a military unit to help keep track of which Service Members need to do which trainings.)
I need to take a bunch of data (on different sheets, all exported from the same location and formatted exactly the same) and copy them into one master sheet, but with the data inverted...
I have a bunch of sheets (like 25) with a list of names (and other administrative data) that shows who has completed a specific training, each sheet being for a different training. Instead of deficiencies by training, I'd like to have deficiencies by name.
The exported data is always formatted like so:
Title of Training
Last 4 Last Name First Name Rank Unit MOS Skill Level Most Recent
xxxx Last First RNK Unit MOS SkillLevel Date
I'd like a Master Sheet that looks like this:
Training Deficiencies
Last 4 Last Name First Name Rank Unit MOS TitleA TitleB etc
xxxx Last First RNK Unit MOS x x x
xxxx Last First RNK Unit MOS x
xxxx Last First RNK Unit MOS x x
Skill Level and Most Recent will be different for each training, and are irrelevant for the master sheet. The Titles (TitleA, TitleB, etc) can each be copied from Cell(1,1) of the respective sheet, and is also the title of the sheet itself.
I created a sheet with everyone in the unit, so my first step is to create the master sheet (I just delete the whole sheet and create it again):
Sheets("MasterSheet").Delete
Sheets("DataSheet").Copy After:=Sheets("DataSheet")
ActiveSheet.Name = "MasterSheet"
Cells(1, 1).Value = "'Master Sheet"
What I can't figure out how to do is loop through the Last4 on the Master Sheet and compare them against the Last4 in each training sheet.
So for each training sheet:
I want to create a new column on the MasterSheet with the training title as the column heading
Loop through each name on the training sheet and find that Service Member's row.
Put an "X" in the respective training column for that Service Member.
After that, I'd like each Service Member to be highlighted Green, Yellow, or Red based on the number of X's in their row. I think once I get the data copied I'll be able to figure out the highlighting and other formatting.
Thanks again for your help. I can't begin to express how much time this will save (it's currently done by hand). I've been on Google all day and I can find snippets of stuff but I don't really know how to put it all together. I'm using Excel 2007. I have an IT background and understand some code, but it's been a very very long time since I've done some real coding, and VBA is really confusing me.
Thanks again for your help in advance!
I would do like this
create a scripting.dictionary
add all last4 from all sheets to the dictionary
loop the dictionary and output all keys on the master sheet and set the value for each key to the row number
loop all sheets again and look up the row number in the dictionary and set cell to 1
create a formula to sum per row and use conditional formatting for colors
(And use cell format "'x';;' if "x" is a hard requirement)