Hey. I urgently need some help on building up a complete table using VBA.
I have got data from two seperate sources of data and i need to put them into same table based on one of the category "Car". I've uploaded an example here .http://www.speedyshare.com/files/23058842/abc.xls
Quick and dirty to do this one time you can do this with the VLOOKUP worksheet function. Enter =VLOOKUP(B2,$F$2:$I$6,2,FALSE) into D2 and =VLOOKUP(B2,$F$2:$I$6,3,FALSE) into E2 in your example and then copy/paste the two cells down to see what I mean.
Writing the equivalent VBA will take a few more minutes. If the solution is reusable let me know and I'll spend the requisite few minutes, but be advised the VBA will vary slightly depending on the real sources of each of the tables of data (in their own worksheets? in their own workbooks?)
Related
sheet 1 have 400 columns and data row upto 10000 rows, i want to compare with sheet 2 it has 600 columns means with additional columns in different order.
Compare sheet1 columns data with sheet2( as different column order) and highlight difference in sheet 2 and put difference in sheet 3 with highlighting the cell for mismatch, im new to VBA need your support,
you can highlight any one column as a primary column in sheet 1
Instead of hoping someone will write your code or teach you from scratch, you might have better luck with putting some research into how to do this with Excel's built-in tools. Therefore, my answer is "don't use VBA" — organizing data is what Excel is meant for and there is plenty of built-in functionality that you're probably not aware of.
First, there's Spreadsheet Compare (available in certain versions), which compares two workbooks (or two versions of the same workbook) and helps you see and organize differences between them. You can also identify potential issues, such as changes in formulas or calculations, or manually entered values.
Also built-in, see Consolidate data in multiple worksheets, allowing you to summarize and report results from separate worksheets into a single document. The sheets can be in the same workbook, or in other workbooks. When you consolidate data, you assemble data so that you can more easily update and aggregate as necessary.
If the columns are in different orders between the worksheets and that causes an issue for you (or for the built-in tools) is a problem, a simple fix is to simply sort the columns alphabetically on both sheets. In order to do this you just need to choose Left-to-Right in the Sort Options.
I'm sure there are other relevant features I'm not thinking of; take a look though "all" the commands available on your version's ribbon to see if there are other commands you're not aware of.
There are also a number of worksheet functions that could also help with a process like this. Exactly which ones depends on your needs (impossible for others to advise on without knowing the details of your current organization method).
The Insert Function Dialog
Off the top of my head, VLOOKUP, HLOOKUP, INDEX, MATCH, FIND, MID, LEFT and RIGHT could all potentially be beneficial to this task. (And still, no VBA required.) Find out more on those at the official Categorized List of Excel Functions, and also see the Lookup Functions section specifically.
Finally, there are a number of free or paid third-party add-ins specifically for Comparing & consolidating worksheets. For example, here is a lengthy list of the comparison functionality offered by DiffEngineX.
It's very common for Excel users to have a task at hand and assume that it's necessary to dive into VBA, without realizing Excel already provides the functionality they need. As a rule of thumb, ask yourself "Is this unique, or is this something that someone might have needed to do before?" If its not unique, chances are it's either already built-in, or there's an existing solution somewhere online.
I am in the process of creating a costing summary workbook. My main summary sheet lists a job category and then 4 rows of cost breakdown before the next category is listed. On another sheet, I have a template that the user will make a copy of for each month, which breaks down weekly work hours and then allocates hours from each employee/plant to against a job category. Please see attached pictures.
Summary Sheet -
Template Sheet
My goal is to have the number of columns on the template increase/decrease as categories are added to or removed from the summary sheet. I already have a cell that contains a count of coloured rows (category titles), and i figure i should be able to use this to determine the amount of rows that need to be added to or removed from a table. I can't think of any ways for this to be done without macros or VBA code of some kind, which I am open to but I would like to minimise the use of.
Can anyone provide me with some code or a push in the right direction for this kind of function? Category names will be stored in column A, or my count is stored in B84. Columns for each category start from column S in the template sheet.
Kyle, you can visit the following sites with a lot of vba beginners information.
http://www.excel-easy.com/vba.html
http://www.homeandlearn.org/
https://www.tutorialspoint.com/vba/
Try implementing your idea using pseudo-code.
http://www.vikingcodeschool.com/software-engineering-basics/what-is-pseudo-coding
https://www.youtube.com/watch?v=4G0EYfrrDT8
https://www.khanacademy.org/computing/computer-programming/programming/good-practices/p/planning-with-pseudo-code
Once you be able to write your code and you are having some code error or problem you cannot find a solution in the web, come again and ask specific questions, there are a lot of experienced programmers that will be happy to help you to solve your coding problems.
So I'm in a rush to put together an excel file for something quick and dirty at work. I've spent several days learning VBA / macros and have learned many individual pieces needed for this, but putting them all together is just not working how I'm looking for.
So I'm taking something similar to the following table of data and trying to reorganize it:
(I can't post the image bc of rep)
![Sample Data Table] https://imgur.com/a/FrwEp
Data in columns d-f are all a list of stuff. What I want to do is start with the first date in column D, find the range of where it fits in column a and copy the data there. For an expense report for example - e1:f1 data would get copied over to b1:c1 since it corresponds with that as the date range. In a nutshell, dates in column A are income dates. They are set to pay all items listed on the right scheduled to be paid before the next pay date. See the finished example here:
![Final Sample Data Table] https://imgur.com/a/niaqB
How might you throw this together to make it work. I'm looking for simplicity as I'm gonna have to heavily modify it to what its actually being applied to.
Sorry for the weird post, this is my first time creating a post myself :)
A handy way to get started with VBA is to record a macro of the actions you need to duplicate, and then analyze the macro's generated VBA code, line by line, revising the code to fit your needs.
(Also: Using Comparison Operators in VBA)
I will briefly explain what I have and need here, and later if I can, I will edit this post and add a reproducible example.
My project:
Query data from Oracle databases into one worksheet in Excel, then use a LOOKUP procedure to copy data into an editable table in a second worksheet. The second worksheet needs to be in a table format for filtering, and have a drop down option to filter the data by date ranges. The data needs to be refreshed 1-2 times a week only by 1-2 approved staff members.
Concerns:
Per suggestion I installed Power Query for Excel 2010, which required dependencies before it could work. The convenience factor is great and it makes it so that SQL queries can be edited without messing around in VBA code. However, the dependencies setup (Oracle client for data connections) limits casually deploying this as a solution.
The data connections and queries and the data lookup could all be done in VBA and assigned macros.
Questions:
Should I use Power Query to query the data and then a VBA for the second sheet LOOKUP and date range filtering -- or should this all be written in VBA Excel Macros?
Which is more future proof friendly? Are there any advantages for using Power Query that would make this task more edit friendly for non-coders?
Thanks!
This probably can be solved with PowerQuery only, without VBA. I wouldn't recommend you storing queries in Excel table, the best is to move it on a server. A view or a function would be suitable. Querying the database, editing this view/function will work for only for only approved users.
This is more secure and will require only 1 Excel workbook. In PowerQuery, you can refer old copy of the table at the moment you refresh it, therefore you can keep entered data and get new.
Your project seem to me as an ad-hoc solution.
Would you please help me (total beginner) to prepare a VBA macro that would open a sheet on the background and import specific selection as shown below:
Let's say we have downloaded wordcount analysis (xlsx) like this downloaded from a CAT tool for testing.
Now I would need to add a macro to my main sheet that would read lines starting (Column A) with "All". If "All" then I'd need to record columns of that line (specficilly Columns A - O) in array / hashtable?.
Please take a look at this image that summs it all (better than explaining it for me :-)
Let me know in case you need to know more details.
All tips / suggestions are greatly appreciated.
Many thanks!
My suggestion (I'm a beginner too) would be to use the Macro Recorder. Great tool to learn (example).
start recording
filter for 'ALL'
copy/past the Cells
stop Recording
Then have a look at the recorded code and adjust it :)
Looking at your data and the final layout you are looking for, using a Pivot Table would provide you with all of the flexibility you need.
You can:
filter which data to display
generate calculated values based on data in other columns
choose what order your columns are displayed
dynamically change the layout if you decide you want a different view
From your data, I was able to generate the following Pivot Table in about 15 minutes.
There are several good, simple tutorials on building Pivot Tables. A Google search will turn up plenty.
Things you will need to learn about for your particular problem:
Classic display (I used the classic display to get this particular layout)
Calculated Fields (many of the columns in the pivot table are calculated based on your spec). There is a maximum string length of 255 characters for a field calculation, so you may need to rename some of the columns in the original data set.
Of course, basics of Pivot Tables
Loading new data and updating your pivot table
Good Luck!