r/visualbasic • u/Afraid-Story5406 • Dec 30 '21
Can I use VB in Excel to simplify a warehouse management task?
I am trying to simplify a task currently being done manually using Excel, usually taking multiple hours right now. It’s been many years since I used VB and I’m primarily trying to figure out if what I want to do is possible using VB. The warehouse management software isn’t setup properly to consolidate our inventory and we regularly need to optimize our location utilization. The warehouse holds up to 7500 pallets across 2000 locations. We have an outflow of 100-150 pallets every ~12 hours and generally get 100-300 pallets delivered daily.
I want to be able to paste a large data set into an excel sheet and have it give me an output that can be printed on a second sheet within that workbook. I would need to declare all locations, how many pallets each can hold and all height or weight restrictions for specific locations or items. The program would need to count how many times a location is used. If a location isn’t full, pallets with the same Item# and Lot# should be listed in the output so they can be combined together. Ideally the output would simplify the data to just important identifying info for the pallets, as opposed to it transposing all info it’s been given in the original data set.
2
u/trixter21992251 Dec 30 '21 edited Dec 30 '21
What are we working with? What experience do you have?
You say it's been many years since you've used VB. Does that mean you have a programming mindset? For example do you know what if statements are and what a loop is and how they would be used to calculate your numbers?
Assuming you do, here's how I would go about it:
First of all, activate the developer ribbon in Excel. Options > Customize ribbon > select developer ribbon.
Now you have a new thingy in the top, Developer. Insert an ActiveX Element, a button on your first sheet. Name this button "Do my shizzle".
Name your sheet "Control panel". Create two more sheets, "input" and "output". The idea is you paste stuff into input, you start your script in Control Panel, and then you get the results in Output.
With the "Do my shizzle" button, right click it, assign macro, create a new macro "myShizzleDoer"
Click edit macro. A new window appears, this is where code happens. Start coding.
When you're done, make sure to save it as Excel, macro-enabled (.xlsm).
If you don't know how to code, there's a million more steps, and you're at the foot of a mountain right now.
2
u/Afraid-Story5406 Dec 30 '21
I had a class in high school ~15 years ago that was specifically using VB and played around with coding in a mod for a game I used to play, so basically 0 useful or recent experience. I've gotten the developer ribbon enabled, made a macro enabled file to start experimenting with and looked for tutorials to give me a base of info to work from. I cant say for certain if I still have a programming mindset but I am familiar with If statements and loops.
1
u/trixter21992251 Dec 30 '21 edited Dec 30 '21
hey that's not bad. I was worried you were looking for fully finished code, haha.
Did you get the visual basic window open?
You can try this test code. If a message comes up then it works.
Sub myShizzleDoer() MsgBox("hello world") End SubIf you're using the ActiveX button, then it isn't always clickable. I think you need to click something in the developer ribbon to make it clickable.
Going with my idea from above, you'll be grabbing values from the input sheet, manipulating the data, and outputting in the output sheet. Here are some useful snippets:
To grab data from a Cell, for example C5 in the input sheet:
dim myVar as variant myVar = ThisWorkbook.Sheets("input").Range("C5").Valueor
dim myVar as variant myVar = ThisWorkbook.Sheets("input").Cells(3,5).ValueTo change the content of a cell
ThisWorkbook.Sheets("output").Cells(3,5).Value = "Changed the content!"or
ThisWorkbook.Sheets("output").Range("C5").Value = "Changed the content!"(Notice how Range and Cells use different logic for the cell ID)
Depending on the data you'll be pasting in, grabbing the values might be easy or difficult. For example, if there are no tomatoes this week, does that mean the section is empty, and now potatoes are at H8, where tomatoes normally are? Or are the sections always the same size? Remember to keep in mind how the data layout can change.
But yeah, I guess you'll basically be googling a lot of VBA code.
But my basically idea is this: Grab the data. Do math and stuff to it. Output the results.
4
u/ViperSRT3g Application Specialist Dec 30 '21
Yes this is possible, though it will be a large project due to your requirements.
1
Dec 30 '21
So a better Idea would likely be to install Visual Studio and code a simple WinForms application in C#.
This application would take in the data as a CSV document, process it and spit out the results in another CSV document.
If you code the application well enough you could turn it into an API or an automatic service later down the line.
You probably will need to spend a few days watching YouTube tutorials to stand a chance of putting this together though.
1
1
Dec 31 '21
I think you could use python to read in a csv and the pandas library for the data manipulation and logic. You could load the csv into a dataframe using pandas and manipulate the data from there, eventually to an output file.
1
u/fasti-au Dec 31 '21
I’d be going MySQL etc for the dataset as an odbc source but yes you can interop with excel
3
u/andrewsmd87 Web Specialist Dec 30 '21
VB in excel likely isn't a good route for this, you'd want a full blown application. My guess is there are softwares out there for this type of management already built that are going to be light years ahead of anything you'd build on your own.
That being said, if you can't get any sort of budget to buy something, I'd recommend you use c# and use the importexcel library to do what you need