|
Is it possible to write a script that will go through a spreadsheet, and if a row has a value, hide that row? I've started a new job and am trying to teach myself python scripting at the same time. Today I was tasked with reading through a spreadsheet, and if a cell had a certain string, I wanted to hide that entire row. Tedious stuff, and I'm guessing there is a way to automate it. I think i can fuddle my way through writing a basic script but I'm unsure how to issue a "hide row" command.
|
# ¿ Jun 27, 2014 23:47 |
|
|
# ¿ May 12, 2024 01:25 |
|
Old James posted:
Thanks for this. A couple of dumb questions. What language is this, VB? How would I adjust it if the keyword I'm looking for is either "nausea" or "vomiting". The cell may have both.
|
# ¿ Jun 28, 2014 01:20 |
|
I've been tackling a side project at work with Perl. I have a working solution but its a pretty shoddy hack. I'm thinking of re-writing the entire thing in Excel and VBA as a learning exercise. Outside of the taskscheduler, do these pseudo steps look possible entirely within Excel/VBA? 1. TaskScheduler to launch Workbook 2. Macro executes when Workbook is launched that: - Copies pipe-delimited text file from network folder to local folder - Loads that delimited file into workbook - Parses delimited file, pulling out needed information and spreading it over 6 named worksheets - Send each worksheet to a different specified network printer - Bonus step: zip delimited file and move to different folder - Close workbook and exit Excel
|
# ¿ Aug 27, 2015 00:52 |
|
fosborb posted:Schedule a repeating meeting in Outlook and trigger VBA off a combination of Category and Subject for your taskscheduler functionality! My work uses Lotus Notes.
|
# ¿ Aug 27, 2015 16:01 |
|
*Ignore, figured out the problem.
Hughmoris fucked around with this message at 05:04 on Aug 29, 2015 |
# ¿ Aug 29, 2015 04:40 |
|
fosborb posted:here, try this: Thanks for this. I'll see if I can get my hands on it. In the meantime, I'm getting tripped up. If I run this code with worksheets("ALERTEXTRACT") selected in the background, it works fine. If I run it with Worksheets("Sheet1") selected, it gives me the runtime error '1004': Method 'Range' of Object'_worksheet' failed. Why does it toss me that error even though I'm explicitly naming what worksheets I want to read from? Also, is this code considered "good practice" for iterating over a column of unknown length?? Visual Basic .NET code:
Hughmoris fucked around with this message at 01:42 on Aug 30, 2015 |
# ¿ Aug 30, 2015 01:22 |
|
fosborb posted:Great VBA stuff... Wow, thank you for taking the time to write that up. The read file for this project is of unknown length but typically 220k+ rows. I'll put up the final version of the script when I finish it, for critiquing. Also, that benchmarking tool looks pretty handy. I'm curious how performing these actions natively within VBA will compare to my Perl script that accomplishes the same thing.
|
# ¿ Aug 30, 2015 04:12 |
|
fosborb posted:Your read file is pipe-delimited text, not an xls/xlsx, right? I'd expect Perl to smash the gently caress out of VBA. A regex looking for "PHYSICIAN CONSULT" after the 16th | and looking back to the beginning of the line to the first | should return exactly what you want. Cycle through that and kick it out to whatever. Yeah, Perl flies through the file but the kicker is that I also need to print these sheets to different network printers and VBA seems to handle that like a champ. Here is where I ended up last night after staying up way too late writing code. This is meat of it: Visual Basic .NET code:
|
# ¿ Aug 30, 2015 22:24 |
|
Cast_No_Shadow posted:Out of interest have you tried loading into and looping through an array and setting the value of each cell individually? Never tried it at what i assume is (200k x 4) 800k lines but for an order of magnitude lower i believe it can be quicker. Turn off calculations and screen updating. I haven't tried that method yet but I'm going to. Once I have a full working version using my current method, I'm going start over and try different techniques to improve the speed. Right now it takes about 12 seconds to run, but the starting file is roughly (200k x 15) cells.
|
# ¿ Sep 2, 2015 23:11 |
|
I'm a bit stumped on a problem. How do I execute a macro after a user clicks the Refresh All button? I have a fully functioning macro intended but I'd like to have it key off the action of Refresh All, instead of the user having to manually launch the macro. My googling is not turning up any examples I can get working. *Disregard. I got it working. Here's some info I used incase anyone needs to reference it in the future: https://excelandaccess.wordpress.com/2014/01/18/create-beforeafter-query-update-events/ Hughmoris fucked around with this message at 01:43 on Sep 16, 2015 |
# ¿ Sep 16, 2015 00:21 |
|
For you VBA wizards out there, do you use other languages for problems that don't necessarily need a spreadsheet? For instance, I need to loop through a directory of folders and pull out csv files to combine into a master CSV, then do some parsing. Typically I'd use Python but it seems VBA can accomplish just about anything with all the reference libraries available to it. The feeling I get from reading various forums is that a lot of people use VBA as the last option.
|
# ¿ May 15, 2016 02:13 |
|
ShimaTetsuo posted:Pretty sure the libraries you're talking about are not specific to VBA and could be used from most any language (COM libraries and whatnot; the world of "native" VBA libraries is basically non-existant afaik). I wouldn't recommend anyone use VBA for anything unless you are already using it for related things (I have a massive legacy VBA code base to maintain and extend). If this is just a simple task that you're going to do once and throw away, it doesn't really matter what you use. fosborb posted:VBA is best used to slightly extend the functionality of Office products. If normal, out of the box use of Excel or Word or Access, etc isn't 95% of your solution, chances are you have better options out there. Thanks, that's about what I expected. I've accomplished a few neat macros with VBA a little while ago out of necessity and was just curious if I want to fall further down that rabbit hole. I don't think I do.
|
# ¿ May 18, 2016 03:09 |
|
This is more of a VBA question than Excel but I'm thinking this thread if my best hope for VBA experts. For work, I'm part of a 25-person committee that makes decisions on certain topics. What I would like to do is create a questionnaire or form of some sort that can reside in an email and be sent out, and the recipients can answer the 5 or so questions with a YES/NO/MAYBE. I'd then need a way to log/track the answers from all the recipients. I have Outlook and Excel 2013 to work with. Any ideas on a simple way to go about this? It looks like there is a simple "Poll" type email that Outlook can do but I think its only good for 1 question. I'm thinking I'll need to create some sort of form with VBA? Hughmoris fucked around with this message at 03:39 on Sep 17, 2016 |
# ¿ Sep 17, 2016 03:32 |
|
fosborb posted:Just use Survey Monkey. Literally the entirely of Corporate America uses it for bullshit one off polls. Yeah, Survey Monkey would definitely be the easiest way to go about it. I'd like to try my hand at it as a learning exercise. Am I on the right track, thinking I can build a VBA userform inside an outlook email and the recipients somehow submit their answers back to me?
|
# ¿ Sep 17, 2016 04:55 |
|
fosborb posted:If you're on a committee of 25 it sounds like you're in a larger company. Check to see if you have Microsoft InfoPath. That + SharePoint could probably solve your problem. Link. mystes posted:Even if this is possible, you definitely should not do this. You should not be emailing random VBA code to people to execute. Also, you would still need a way to receive the answers, and sending an email without user intervention or something like that would be extra terrible. Thanks for the ideas. After thinking about it for a few days, ya'll are right. It isn't worth taking on the headache, and I'll see if others want to use other means.
|
# ¿ Sep 20, 2016 01:37 |
|
Being a VBA novice, I about had a fit today trying to get regex to work for me. I have a column of cells, each with a format like: quote:--------------------------------------- It's always a volume (250), a line of garbage, then the unit number (W123456789123). I want to extract the volume and its associated unit number, in pairs. Ideally, I'd end up with: code:
Any advice on how to go about this? I was following this example on stackoverflow, example #4 of the top response. http://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops Hughmoris fucked around with this message at 01:34 on Dec 16, 2016 |
# ¿ Dec 16, 2016 01:30 |
|
mystes posted:If the data is in exactly that format, surely you don't need a regex at all, you can just iterate over the cells (or rather the value array of the range, which is faster)? The volume and unit number always have one line of text separating them, but there is a random amount of data before and after them. The volume is always 3 digits, and the unit number is W + 12 digits. Is there an easy solution that I'm missing?
|
# ¿ Dec 16, 2016 03:11 |
|
Convicted Bibliophile posted:I have a small task I need to accomplish in an existing excel spreadsheet but I'm a total newbie when it comes to vba/macros in Excel. Instead of posting it here (I'm not sure how long it would take and I don't want to waste people's time), does SA have a place where you can pay people to do small things in Excel for you? You might have some luck here: "Request a tiny custom app" http://forums.somethingawful.com/showthread.php?threadid=2415898&userid=0&perpage=40&pagenumber=1 Hughmoris fucked around with this message at 21:57 on Dec 26, 2016 |
# ¿ Dec 26, 2016 19:13 |
|
Phraggah posted:Not sure if you were able to figure this out. First I'd define two patterns. This assumes what you're looking for will always be in its own cell... Thanks for this. This small project has taught me quite a few things: more VBA, slicers, Power Query, and the fact that Excel has a built in data form that you can use to query data. I thought I was going to have to create a VBA userform so that others could easily search the parsed data.
|
# ¿ Jan 2, 2017 15:59 |
|
Can someone tell me if this can be accomplished in Excel? I'm looking at a datasheet that has medication administration times. Each order has an allowed frequency that dictates how frequent a medication can be given. If it's administered sooner than its allowed frequency than an alert should fire and notify the user. In the table above, med_id ->1111 was given for the first time at 0100. Since it has a frequency of "every 6 hours" then it should not be given again before 0700. However, it was given again at 0645 so the alert should fire. I want to look at every administration in the sheet and add a Y/N on whether or not that administration should have fired an alert. * I guess to simplify, I need to look at each TIME_GIVEN and see if the same med_id was previously administered within TIME_GIVEN - FREQUENCY Hughmoris fucked around with this message at 05:31 on Aug 12, 2017 |
# ¿ Aug 12, 2017 05:16 |
|
fosborb posted:Woooo! You are a wizard. This is great, thanks!
|
# ¿ Aug 12, 2017 15:29 |
|
I'm stumped coming up with an Excel solution for this problem. Say I have a table of employee names, boss names, and the amount of money each boss gave to an employee. What I'd like to end up with is a summary of some sort detailing who gave to each employee. The amount given doesn't need to be in the summary. The summary doesn't have to be pretty, just such that you can tell at a glance who donated to a given employee. So, something like: code:
|
# ¿ Dec 1, 2017 07:50 |
|
Fingerless Gloves posted:Quick and dirty, set up an if statement table next to it. Maybe something like Thanks!
|
# ¿ Dec 1, 2017 16:47 |
|
fosborb posted:Awesome excel stuff... Great writeup. I don't work with an excel-savvy team so its nice to see other's thought process as they work through problems.
|
# ¿ Dec 4, 2017 14:28 |
|
Today was great. I noticed that one of the members on our project team was doing repetitive work in a spreadsheet. I reached out to see if he'd be interested in learning how to automate some of his work, and he was. He showed me one of his tasks which entails running a report, combining workbooks, formatting columns, adding formulas and saving. He has 100+ reports he needs to perform this on. The same exact steps for each one. The look on his face when I showed him how to record a macro and run it on each report was amazing. The simple macro will probably end up saving him 35+ hours of work on this project. Even better was seeing the wheels turning in his head in realizing the potential of macros, and automation in general.
|
# ¿ Dec 7, 2017 02:13 |
|
I need a little guidance on an excel stumper. I have a workbook with a lot of worksheets, each worksheet being named after a store. I have a list of default users that are found in every worksheet. The listing of the users is the same for every worksheet. John will always be in row 2, Phil in row 3 etc... Finally, I have a worksheet call Total that would have the list of users and the COUNT of their entries in each worksheet/store: I have a lot of stores, and a lot of users. For this Total table, I'd like a formula that would reference each worksheet dynamically using the column header (which is the store name and appropriate worksheet name) and calculate the COUNT of each user for each store. I was poking around using COUNT(INDIRECT(....) but I couldn't get the relative cell range to work. John should be B2:D2, Phil is B3:D3 and so on. I hope that makes sense. Any help is appreciated.
|
# ¿ Dec 19, 2017 05:39 |
|
kumba posted:The idea is you're counting the number of non-blank cells in columns B:D for each user, yeah? In that case, in your Total sheet in cell B2 (or wherever it is that John & Amazon intersect) you can use this: Thanks!
|
# ¿ Dec 20, 2017 01:31 |
|
Anyone have guidance on how to use Excel as a front-end for SQL Server? Or should I even want to do that? I recently was given database access and have been using SSMS to write basic queries. The database has hundreds (if not thousands) of tables. What I'm currently doing is running the query is SSMS and exporting to CSV, then opening that CSV in Excel and putting together simple charts etc... Is there a more streamlined way to approach this?
|
# ¿ Jan 13, 2018 00:13 |
|
fosborb posted:You should be able to make a data connection in Excel that has your queries, then feed that to a table. Thanks for the ideas. I might have a Tableau license available to me, so I'll read up on that.
|
# ¿ Jan 15, 2018 01:14 |
|
Does anyone fool with Power Query and Power Pivot? If so, what are your typical use cases? I'm trying to figure out if it's worth the effort of a deep dive and learning. Hughmoris fucked around with this message at 04:54 on Feb 23, 2018 |
# ¿ Feb 23, 2018 04:51 |
|
kloa posted:I used to work with some analysts that got into it, and by proxy I sat in with them just to learn for fun. Speaking of SSAS, do you know of any recommended learning resources? I was just recently given sql/ssrs/dwh access and am trying to futz my way through but I really don't have a great learning path identified.
|
# ¿ Mar 2, 2018 18:19 |
|
Sri.Theo posted:Thanks! I might do that as I can’t get the pivot table to show what I want. If I drag Deadline into the ‘Row’ box and removing months and quarters it won’t let me put ‘status’ in the column box to show it the way I want. If you do a decent amount of work in Excel then it would pay to become more familiar with pivot tables. This guy has a Excel series that covers all sorts of topics but here is one specific to pivot tables: https://www.youtube.com/watch?v=e-yuYNgsHAk
|
# ¿ Jul 20, 2018 18:59 |
|
This is tangentially related to Excel and the O365 ecosytstem, not sure of a better thread to put this in. Has anyone used Microsoft Flow / Power Automate? I just discovered it, and am currently a solution looking for a problem. I'm looking at my daily/weekly tasks and seeing how I can use it to automate some Excel -> Outlook -> OneNote flows.
|
# ¿ Sep 13, 2020 19:19 |
|
What do you mean Excel doesn't have unlimited rows? https://arstechnica.com/tech-policy/2020/10/excel-glitch-may-have-caused-uk-to-underreport-covid-19-cases-by-15841/ Possibly 16k UK covid cases went untracked due to exceeding spreadsheet row limits. Hughmoris fucked around with this message at 20:00 on Oct 5, 2020 |
# ¿ Oct 5, 2020 19:52 |
|
Has anyone poked about Office Scripts much? I just found that my O365 subscription for work includes it. Been reading a few articles on it but I haven't really found a use case yet.
|
# ¿ Feb 28, 2021 20:49 |
|
Harminoff posted:Is anyone watching Excel Esports on ESPN? I had no clue that was a real thing. Pretty cool. Also, there is a pro streamer scene around Excel: https://www.youtube.com/watch?v=xubbVvKbUfY
|
# ¿ Aug 10, 2022 22:16 |
|
Strong Sauce posted:https://twitter.com/benlcollins/status/1562546876024778753 Everyone in the scene knows that XLOOKUP breaks the meta: https://www.youtube.com/watch?v=ICp2-EUKQAI
|
# ¿ Aug 25, 2022 22:09 |
|
Any M-code gurus out there using it daily? If so, your thoughts? I've recently started exploring Power Query inside Power BI, seems like a fun little language.
|
# ¿ Aug 27, 2022 04:13 |
|
Is there any uglier language than DAX? Survey says: no.
|
# ¿ Mar 13, 2023 20:15 |
|
|
# ¿ May 12, 2024 01:25 |
|
DRINK ME posted:I’ve just been using DAX for a couple of weeks in power bi and it’s ain’t fun. I have zero affiliation with these guys but I've found their free "Intro to Dax" course to be pretty approachable: https://www.sqlbi.com/training/ I always found an online DAX repl which I've been poking about with.
|
# ¿ Mar 14, 2023 03:19 |