Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
kumba
Nov 8, 2003

I posted my food for USPOL Thanksgiving!

enjoy the ride

Lipstick Apathy
I've had those kind of problems before - if it's a massive file and the sorting is simple, it may be easier to filter and create the order you want in a different sheet via simple brute force copy & pasting as nauseum

If the file is stored somewhere with auto save on (e.g., onedrive or SharePoint) try turning that off - for sorts on big files I've found that to be a huge bottleneck

Adbot
ADBOT LOVES YOU

fosborb
Dec 15, 2006



Chronic Good Poster

HootTheOwl posted:

What if the cell is create via a forumula?

that's where turning off the auto calculations comes in. it sounds like the sort is making all 11,000 cells recalculate (and more if other sheet/cells are also referencing the sorted columns) and that's causing it to hang up

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN

kumba posted:

I've had those kind of problems before - if it's a massive file and the sorting is simple, it may be easier to filter and create the order you want in a different sheet via simple brute force copy & pasting as nauseum

If the file is stored somewhere with auto save on (e.g., onedrive or SharePoint) try turning that off - for sorts on big files I've found that to be a huge bottleneck

Yes, auto-save can be a real killer and is one I come across in my day job. If the calculations are taking a decent amount of time Excel can try auto-saving while that is going, and I think it gets into a tizzy because it usually calculates and then saves but also doing that while already calculating.

Ham Equity
Apr 16, 2013

i hosted a great goon meet and all i got was this lousy avatar
Grimey Drawer
I have a report pulled from a database that has a description field. Most--but not all--of the descriptions contain an ID number along with a description of the product (e.g. "this is a can of red paint, product ID F1234567, that contained blue paint instead"). Product IDs are always F followed by a seven-digit number. Is there a way for me to check the description column for an ID number, if it finds one there return the ID number but nothing else from the description, and if it does not return "N/A"?

Bonus optional question: while exceedingly rare, it is possible for the description to contain two ID numbers, is there a way to additionally validate for that, and return both?

I've looked at the various formulas, and nothing I've tried seems to be able to return just the string I'm looking for; I can get it to find the ID numbers by doing a wildcard match for "F???????", but can't figure out how to get it to return that with XLOOKUP,. MATCH, or INDEX. I could probably get it done in Powershell, but I'd prefer a user-friendlier option.

Zorak of Michigan
Jun 10, 2006

I think you're going to the up needing to add something that can do regular expressions to really zero in on that. You could approximate it with SEARCH for "F???????" and then using the result in SUBSTR, but you would get every eight letter word starting with F, and it wouldn't work if the cell had multiple IDs. Actually the multiple ID problem is beyond my ken anyway.

AG3
Feb 4, 2004

Ask me about spending hundreds of dollars on Mass Effect 2 emoticons and Avatars.

Oven Wrangler
I'm using a VBA code I googled to alter the enter key behavior for my sheet, to make it move right by default instead of down. The problem is, this code affects Excel permanently even in other files and persists through Excel restarts, until I manually run the code again to toggle it off. It looks like this:

code:
Sub EnterKeyBehavior()

If Application.MoveAfterReturnDirection = xlToRight Then
    Application.MoveAfterReturnDirection = xlDown
Else: Application.MoveAfterReturnDirection = xlToRight

End If
End Sub
Is there an easy way to make it turn itself on when the file is opened and turn itself off when it's closed?

HootTheOwl
May 13, 2012

Hootin and shootin

AG3 posted:

I'm using a VBA code I googled to alter the enter key behavior for my sheet, to make it move right by default instead of down. The problem is, this code affects Excel permanently even in other files and persists through Excel restarts, until I manually run the code again to toggle it off. It looks like this:

code:
Sub EnterKeyBehavior()

If Application.MoveAfterReturnDirection = xlToRight Then
    Application.MoveAfterReturnDirection = xlDown
Else: Application.MoveAfterReturnDirection = xlToRight

End If
End Sub
Is there an easy way to make it turn itself on when the file is opened and turn itself off when it's closed?

I'm looking it up, but you're applying your change to the application object (excel) when it sounds like you only want to apply it to she worksheet, which I don't think you can do. Basically you're changing a setting in excel which is why it applies to your other sheets. It's not actually a change to the workbook, but to excel itself.
I also don't think you can use macros to tap into .net events (Ie, When the application closes, do something)
But I also think you can use windows built in language hotkeys?

e: Yup, this can only be done to applications: https://learn.microsoft.com/en-us/office/vba/api/excel.application.moveafterreturndirection
e: Oh! You can have macros run at prescribed events as documented here oh and there's event handlers too! Ok, give me some time and I think I can do this to you. If you want to do it yourself read this: https://www.exceltip.com/events-in-vba/workbook-events-using-vba-in-microsoft-excel.html Looks like you can just slap these into your workbook.
I wonder if this means you can have a macro which then just updates these handlers for you too?

EEE: Use the activate and deactivate events, imo. This will change the setting every time you enter the sheet and again when you leave it

HootTheOwl fucked around with this message at 13:41 on Oct 13, 2022

Raygereio
Nov 12, 2012

AG3 posted:

I'm using a VBA code I googled to alter the enter key behavior for my sheet, to make it move right by default instead of down. The problem is, this code affects Excel permanently even in other files and persists through Excel restarts, until I manually run the code again to toggle it off. It looks like this:

Another solution might be to use autohotkey? Catch the enter keypress and change it to a tab?
You can get fancy with that by having it run in the background and only be active when that specific Excel sheet is open

Harminoff
Oct 24, 2005

👽
The easiest way would be to just put it in workbook activate/deactiviate


Put this in the ThisWorkbook module


Private Sub Workbook_Activate()
Application.MoveAfterReturnDirection = xlToRight
End Sub


Private Sub Workbook_DeActivate()
Application.MoveAfterReturnDirection = xlDown
End Sub



This way, whenever you click onto that workbook it'll change it to the right direction. When you click into another workbook, it'll change it to down.

tadashi
Feb 20, 2006

Problem: Someone spit out a giant spreadsheet that I'm now responsible for and many of the cells in one particular column have duplilcate data in the same cell.

Example:
  • The second column in the snip below contains a set of addresses that has been repeated 4 times in the same cell.
  • The addresses on each line have similar words or numbers, so I can't use find/replace.
  • There are hundreds of cells like this in my spreadsheet.
  • My spreadsheet has this problem on hundreds of cells but the actual data sets are always different.
  • I can't use "delete duplicates" (maybe) because the duplicate data is in each problematic cell, not in different rows.

The original CSV file exports with the same issue every time according to the person who feeds me the file.
Obviously, they should fix their software but, the point is, I have to work with what I'm given for now.

Solution I tried:
I tried moving the column to a new tab and then I tried using text to columns with a line break as the delimiter (Select "Other" as the delimiter then click the box, then hit Alt+J) but Excel keeps the "3" in the original column and deletes all the other data without moving it into the next columns and I have no idea why so I have yet another problem :smith:

Harminoff
Oct 24, 2005

👽
Can you try putting the text formated as you'd like it and then press Ctrl+e (it should be flash fill but it's only available in the newer versions of excel)

Wandering Orange
Sep 8, 2012

Add the CSV file as a data source (Power Query > From File > From Text/CSV), ignore whatever happens in the first dialog and hit the Edit button to open up the PQ editor. Then on the far right-hand side, click the gear icon to the right of the Source step on this new query and play around with the Line Breaks and Delimiter options. You've kinda already done this so it may not work either. The Transform > Split Column > By Delimiter option may be useful too.

Ninja.Bob
Mar 31, 2005
I would start with something like =left(b2, len(b2)/4)

If the data is more complicated than that I would find the point where the first line is repeated again (i.e. a new line followed by the first line of text) and extract the lines before that.

=LEFT(B2, FIND(CHAR(10)&LEFT(B2,FIND(CHAR(10),B2)),B2)-1)

Also it's ctrl+J not alt+J for a new line character, so that may have been the issue.

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
I’ve done something similar before but had to use code/vba because I couldn’t find a solution that worked in the sheet. I had to google this because I couldn’t remember the steps but pretty much the accepted answer on this.

https://stackoverflow.com/questions/54929316/how-to-delete-duplicate-words-within-a-cell

Then you call that as a formula with your line break as the optional delimiter, usually either char (10) or char (13)

=RemoveDuplicateWords(A1, char (10))

—-

Really odd that the Awful app won’t preview post or post if I use char (10) without the space before the brackets… assume it’s the app but could be the site though.

AG3
Feb 4, 2004

Ask me about spending hundreds of dollars on Mass Effect 2 emoticons and Avatars.

Oven Wrangler

Harminoff posted:

The easiest way would be to just put it in workbook activate/deactiviate


Put this in the ThisWorkbook module


Private Sub Workbook_Activate()
Application.MoveAfterReturnDirection = xlToRight
End Sub


Private Sub Workbook_DeActivate()
Application.MoveAfterReturnDirection = xlDown
End Sub



This way, whenever you click onto that workbook it'll change it to the right direction. When you click into another workbook, it'll change it to down.

Thank you, this works great! Several of the other solutions would've been fine for me personally, I didn't even mind the way it worked originally, but the worksheet I'm making is going to be used by people who can charitably be described as "not tech savvy". I need anything that can make this thing work by itself and not cause more tech support work for me.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
I have a table of data with the following structure with data about ~1000 people.



For each person, the first row has their year, forename and surname. But the other rows for that person are just their class name.

What I would like to do is shorten this down so it just tells their information about a specific class.

If I filter blank rows out, I'd get the names but the class code would be incorrect.
If I filter by just specific class codes, the year/forename/surname would be mainly blank.
Manually adding the year/forename/surname to the blanks would allow me to filter but that's incredibly tedious.


Best solution?

Chickpea Roar
Jan 11, 2006

Merdre!

Sad Panda posted:



Manually adding the year/forename/surname to the blanks would allow me to filter but that's incredibly tedious.


Here's a quick way to fill in all the blanks:
ctrl+a, ctrl+g, "special," "blanks," "=A1," ctrl+enter

Edit: "=A1" should be switched out for the cell above your first blank, so "=A2" in this example.

Chickpea Roar fucked around with this message at 10:39 on Oct 25, 2022

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN

Chickpea Roar posted:

Here's a quick way to fill in all the blanks:
ctrl+a, ctrl+g, "special," "blanks," "=A1," ctrl+enter

That’s the best solution, then you just copy-paste values on the whole table / those columns and you’re home free

Chickpea Roar
Jan 11, 2006

Merdre!

DRINK ME posted:

That’s the best solution, then you just copy-paste values on the whole table / those columns and you’re home free

What do you mean? You shouldn't have to do any copy/pasting, unless I've misunderstood something about the problem.

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
Definitely not mandatory but speaking from personal experience somewhere down the line the data gets sorted and the first user will suddenly have 100 marks for a class because the order has changed and all your =above are looking at the wrong value.

HootTheOwl
May 13, 2012

Hootin and shootin

Chickpea Roar posted:

What do you mean? You shouldn't have to do any copy/pasting, unless I've misunderstood something about the problem.

When they said copy past the values, they meant to strip out the formulas for sorting.

E: Sorry I hadn't had my morning coffee yet and posted this because it took me a minute to understand the connection between what DRINK ME was saying in their two posts. They already said this.

it dont matter
Aug 29, 2008

Can I ask a Google Sheets question here?

I've got two columns, A & B. Both have drop-down menus with YES or NO.

Can I use conditional formatting to colour B red only when A=YES and B=NO ?

esquilax
Jan 3, 2003

it dont matter posted:

Can I ask a Google Sheets question here?

I've got two columns, A & B. Both have drop-down menus with YES or NO.

Can I use conditional formatting to colour B red only when A=YES and B=NO ?

Yes.

In the conditional formula menu, choose "Custom Formula Is" and set it to something like: =and((A2="YES"),(B2="NO"))

And the range should be your data in Column B. The custom formula you use should be the relevant formula for the top left cell of the conditional formatting range - the formula I wrote above was if cell B2 is the top of your data range.

esquilax fucked around with this message at 14:37 on Oct 25, 2022

it dont matter
Aug 29, 2008

esquilax posted:

Yes.

In the conditional formula menu, choose "Custom Formula Is" and set it to something like: =and((A2="YES"),(B2="NO"))

And the range should be your data in Column B. The custom formula you use should be the relevant formula for the top left cell of the conditional formatting range - the formula I wrote above was if cell B2 is the top of your data range.

Yes that worked, thank you.

What if I also want B to turn red if it's empty? Would that be something with ISBLANK ?

HootTheOwl
May 13, 2012

Hootin and shootin

it dont matter posted:

Yes that worked, thank you.

What if I also want B to turn red if it's empty? Would that be something with ISBLANK ?

Have it be red by default and only turn green when it's yes

esquilax
Jan 3, 2003

it dont matter posted:

Yes that worked, thank you.

What if I also want B to turn red if it's empty? Would that be something with ISBLANK ?

You can use ISBLANK(B2) or something like: B2=""

You could implement that either by rewriting the first conditional formula to account for both No and [blank], or add a second conditional formatting formula.

it dont matter
Aug 29, 2008

That's great, thanks everyone.

A Real Happy Camper
Dec 11, 2007

These children have taught me how to believe.
I have a sheet that is being sent to a variety of people to fill out with inventory items, and I want to have a second sheet that can collect the data from all the copies of the first.

I realize this is a bit on the "using excel when you should have a proper database" spectrum, but I'm pretty much just working within the limits of what my IT department will let me do.

Is there a way to set up the data import tools to have a pre-set range that they're querying, and put them in a sheet in a way that doesn't overwrite the data that's been imported previously? Or at least be conditional so that if the location is X, that data is saved in column X, etc.?

I'm basically trying to semi-idiot proof it for my manager. For bonus difficulty, our corporate license is for Office 2016, so running it on that is ideal.

nielsm
Jun 1, 2009



How many recipients do you have that need to fill out the form?

If it's a manageable number, consider making a folder with N copies of the blank form, all named after the recipients, and ask them each to fill out their file in that folder.

You can then have the master workbook use an append query to collect from all the individual workbook files and present in a single table.
By having all the individual files pre-created you can prepare the master workbook ahead of time.


This is of course assuming it isn't a problem that all the recipients might be able to see and mess with each others' files. And also that they aren't idiots who can't follow instructions and maybe instead make a copy of the file to their desktop, edits that file, and then emails it to someone.

A Real Happy Camper
Dec 11, 2007

These children have taught me how to believe.
It's ~30 different branches, with all different levels of ability, so I'll probably just set up a folder for my manager to use, and fill it with blank forms for the time being.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

Chickpea Roar posted:

Here's a quick way to fill in all the blanks:
ctrl+a, ctrl+g, "special," "blanks," "=A1," ctrl+enter

Edit: "=A1" should be switched out for the cell above your first blank, so "=A2" in this example.

Thank you so much. That was absolutely perfect. Never knew that was possible. Saved me so much time.

DarkHorse
Dec 13, 2006

Vroom Vroom, BEEP BEEP!
Nap Ghost

C-Euro posted:

Can you define the values that populate the drop-down list without needing to reference cells elsewhere in the sheet? That appears to be my only way of getting more than one value onto the list.

If you want to get super-fancy you can use Tables and INDIRECT so you only have to define the range once, and it'll update automatically if you add anything to the list of acceptable values. You'll still need a range in the spreadsheet for the list though.

If you have a Table named Options with a column named Choices with all your list values, you can go to Data Validation on a cell and set it to " =INDIRECT("Options[Choices]") "

Modifying the table will modify the pull-down list, so you never need to worry it's grabbing the right range. Nice for adding a quick value to the end, or avoiding extra blanks when deleting unnecessary ones. Plus you can sort the column!

With a little more fuckery you can change which table you reference and make dynamically-allocated pull-down lists!

Hughmoris posted:

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.

Not daily but I used it a bunch for a custom project, it's a fun way to attack some problems sideways

For example

Wandering Orange posted:

Add the CSV file as a data source (Power Query > From File > From Text/CSV), ignore whatever happens in the first dialog and hit the Edit button to open up the PQ editor. Then on the far right-hand side, click the gear icon to the right of the Source step on this new query and play around with the Line Breaks and Delimiter options. You've kinda already done this so it may not work either. The Transform > Split Column > By Delimiter option may be useful too.
Data cleaning like this is a great application for power query/M-code

Wandering Orange
Sep 8, 2012

A Real Happy Camper posted:

I have a sheet that is being sent to a variety of people to fill out with inventory items, and I want to have a second sheet that can collect the data from all the copies of the first.

I realize this is a bit on the "using excel when you should have a proper database" spectrum, but I'm pretty much just working within the limits of what my IT department will let me do.

Is there a way to set up the data import tools to have a pre-set range that they're querying, and put them in a sheet in a way that doesn't overwrite the data that's been imported previously? Or at least be conditional so that if the location is X, that data is saved in column X, etc.?

I'm basically trying to semi-idiot proof it for my manager. For bonus difficulty, our corporate license is for Office 2016, so running it on that is ideal.

A Real Happy Camper posted:

It's ~30 different branches, with all different levels of ability, so I'll probably just set up a folder for my manager to use, and fill it with blank forms for the time being.

I'm gonna pimp Power Query again as this is another great use case for it that doesn't require any coding to set up and would allow you an unlimited number of forms that are all compiled into one master file at the click of the 'refresh' button. The only requirement is that you all have access to SharePoint or OneDrive, including all of your branches, although technically a network shared folder would work too...

Chickpea Roar
Jan 11, 2006

Merdre!

DRINK ME posted:

Definitely not mandatory but speaking from personal experience somewhere down the line the data gets sorted and the first user will suddenly have 100 marks for a class because the order has changed and all your =above are looking at the wrong value.

Thanks, that makes sense 👍

Jack the Lad
Jan 20, 2009

Feed the Pubs

Is there a way to write the name of a named range as text in a cell, then pass the contents of that cell to a formula that parses it as the named range?

For example I want to put BobsFaveFoods in A1 and then use =SUMPRODUCT(COUNTIF(B2:B10,A1)) instead of =SUMPRODUCT(COUNTIF(B2:B10,BobsFaveFoods)) so that I can have this across a bunch of rows/tabs and change which named range I'm referencing on the fly if possible.

Really stumped on this but probably just being stupid.

Lib and let die
Aug 26, 2004

Jack the Lad posted:

Is there a way to write the name of a named range as text in a cell, then pass the contents of that cell to a formula that parses it as the named range?

For example I want to put BobsFaveFoods in A1 and then use =SUMPRODUCT(COUNTIF(B2:B10,A1)) instead of =SUMPRODUCT(COUNTIF(B2:B10,BobsFaveFoods)) so that I can have this across a bunch of rows/tabs and change which named range I'm referencing on the fly if possible.

Really stumped on this but probably just being stupid.

INDIRECT is probably the function you want, it can pass the value of a cell along as part of a formula

HootTheOwl
May 13, 2012

Hootin and shootin

Jack the Lad posted:

Is there a way to write the name of a named range as text in a cell, then pass the contents of that cell to a formula that parses it as the named range?

For example I want to put BobsFaveFoods in A1 and then use =SUMPRODUCT(COUNTIF(B2:B10,A1)) instead of =SUMPRODUCT(COUNTIF(B2:B10,BobsFaveFoods)) so that I can have this across a bunch of rows/tabs and change which named range I'm referencing on the fly if possible.

Really stumped on this but probably just being stupid.

this sounds like a lambda.

DarkHorse
Dec 13, 2006

Vroom Vroom, BEEP BEEP!
Nap Ghost

Jack the Lad posted:

Is there a way to write the name of a named range as text in a cell, then pass the contents of that cell to a formula that parses it as the named range?

For example I want to put BobsFaveFoods in A1 and then use =SUMPRODUCT(COUNTIF(B2:B10,A1)) instead of =SUMPRODUCT(COUNTIF(B2:B10,BobsFaveFoods)) so that I can have this across a bunch of rows/tabs and change which named range I'm referencing on the fly if possible.

Really stumped on this but probably just being stupid.

Using INDIRECT and naming cells will probably do what you want

Lib and let die
Aug 26, 2004

Jack the Lad posted:

Is there a way to write the name of a named range as text in a cell, then pass the contents of that cell to a formula that parses it as the named range?

For example I want to put BobsFaveFoods in A1 and then use =SUMPRODUCT(COUNTIF(B2:B10,A1)) instead of =SUMPRODUCT(COUNTIF(B2:B10,BobsFaveFoods)) so that I can have this across a bunch of rows/tabs and change which named range I'm referencing on the fly if possible.

Really stumped on this but probably just being stupid.

a little more info on the INDIRECT function:

I set up a basic sheet and A1 to BobsFaveFoods and set the named range to B2:B10, the original formula functions as intended, but it also works as such:
code:
=SUMPRODUCT(COUNTIF(B:B,INDIRECT($A$1)))


You can even get really fancy and create formulas from multiple indirect cell references like this:


e: in your case you might want to use something like
code:
=SUMPRODUCT(COUNTIF(INDIRECT($A$1),INDIRECT($A$1)))

Lib and let die fucked around with this message at 03:02 on Nov 8, 2022

Adbot
ADBOT LOVES YOU

Jack the Lad
Jan 20, 2009

Feed the Pubs

Awesome, thank you folks! I feel dumb (but glad) that it was so simple.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply