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
Ragingsheep
Nov 7, 2009
Is there a way to automatically search an excel file for a list of words from another excel file and delete those words if they appear from the first excel file?

Adbot
ADBOT LOVES YOU

Veskit
Mar 2, 2005

I love capitalism!! DM me for the best investing advice!

Ragingsheep posted:

Is there a way to automatically search an excel file for a list of words from another excel file and delete those words if they appear from the first excel file?

Does the column have a single word in it, or does it have multiple words?

Ragingsheep
Nov 7, 2009

Veskit posted:

Does the column have a single word in it, or does it have multiple words?

It'll generally be sentences which may contain one of the words I'm looking to get rid of. Ideally it should go though the whole workbook rather than just a single column.

Veskit
Mar 2, 2005

I love capitalism!! DM me for the best investing advice!
Can you post a visual example because it soudns more like you're doing something in word rather than excel to me.

ZerodotJander
Dec 29, 2004

Chinaman, explain!

wither posted:

Your .xlsx is 404'ing :( Can you email it to me at wither@gmail.com ? More ideas guys!

Edited the link and e-mailing.

Another good tool would be one that took phrases from column A and removed them plus all word order variants from column B.

So for example, Column A contains "pretty things" and "dumb things".

Column B contains "pretty things" "things" "things dumb" "things dumb pretty".

The tool should remove the 1st and 3rd items from Column B.

Ragingsheep
Nov 7, 2009

Veskit posted:

Can you post a visual example because it soudns more like you're doing something in word rather than excel to me.

https://docs.google.com/open?id=0B06cZmYYUgZGQkQ0dDF6ajQ1S00

Data will be stored like that but there be multiple columns of it. Let's say that in a separate file, I have the words "excel" and "powerpoint", I'm looking for a way to automatically delete those words from the first file.

Also, this is probably more a powerpoint 2010 related question but in the office, sometimes people are pasting in charts from excel and they're embedding in the excel workbook rather than just creating a chart linked to the data. I know that you can change the paste option but is there any place you can ensure that the default setting is the linked option? Also is there a way of stripping out the embedded workbook without having to re-paste everything?

Veskit
Mar 2, 2005

I love capitalism!! DM me for the best investing advice!

Ragingsheep posted:

https://docs.google.com/open?id=0B06cZmYYUgZGQkQ0dDF6ajQ1S00

Data will be stored like that but there be multiple columns of it. Let's say that in a separate file, I have the words "excel" and "powerpoint", I'm looking for a way to automatically delete those words from the first file.

Also, this is probably more a powerpoint 2010 related question but in the office, sometimes people are pasting in charts from excel and they're embedding in the excel workbook rather than just creating a chart linked to the data. I know that you can change the paste option but is there any place you can ensure that the default setting is the linked option? Also is there a way of stripping out the embedded workbook without having to re-paste everything?

Are you doing this with a lot of entries and need to constantly update it? Otherwise click crtl F and go to the replace tab and replace those words with a " ". Otherwise the macro recorder is pretty handy. I still can't really grasp how this all works just from that.

celestial teapot
Sep 9, 2003

He asked my religion and I replied "agnostic." He asked how to spell it, and remarked with a sigh: "Well, there are many religions, but I suppose they all worship the same God."
Range.Replace Method

Ragingsheep
Nov 7, 2009

Looks interesting. Thanks.

Monocular
Jul 29, 2003

Sugartime Jones
I'm making a spreadsheet recording continuing education credits for people who attended various courses, and ideally I'd do a mail merge with Word where all the data will appear on a certificate.

Since a few of the courses are worth different amounts of credits, is there a way to define or tag the names of the courses with its respective number of credits? On the certificate I'd like to display the course titles as well as the total credits earned.

odi3
Dec 17, 2003
I am looking to make a template pivot table, where data can be pasted in each month and the results will be displayed in the pivot table.
In a pivot table, is it possible to display a total of max fields?

Example:
Data pasted into worksheet:

John, May, 1
John, Jun, 0
John, Jul, 1
Mary, May, 1
Mary, Jun, 0
Mary, Jul, 1

In pivot table, I am displaying col 1, not displaying col 2, and maxing col 3

Pivot Table Looks like this:

John 1
Mary 1
Is it possible to have the total display 2? (sum of the maxes grouped by name)The only functions available are count, which would display 6, sum would display 4, and count num which would display 6.

Maybe a secondary pivot table or table would work to group the data before the final pivot table?

odi3
Dec 17, 2003

Monocular posted:

I'm making a spreadsheet recording continuing education credits for people who attended various courses, and ideally I'd do a mail merge with Word where all the data will appear on a certificate.

Since a few of the courses are worth different amounts of credits, is there a way to define or tag the names of the courses with its respective number of credits? On the certificate I'd like to display the course titles as well as the total credits earned.

It sounds like you are looking to make a vlookup table.
http://www.contextures.com/xlFunctions02.html

Use the coursename against a secondary spreadsheet with a lookup table in it to get the value of the course

Karl Sharks
Feb 20, 2008

The Immortal Science of Sharksism-Fininism

Is there any way, probably through an add-on, to create a shortcut for formatting part of a cell as a subscript? It gets tedious making all the subscripts by hand and I'm sure there's some better way to do this. I'm using 2010, for the record, and had found something, but it only worked for 2005 or something.

khazar sansculotte
May 14, 2004

I have a large spreadsheet, and I would like to delete all rows whose column B does not contain one of a number of substrings. That is, if the text in column B does not have substring1, substring2, or substring3 in it, I'd like the associated row to disappear. What would be helpful in doing this? I'm hoping I don't have to resort to scripting...

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Ronald McReagan posted:

I have a large spreadsheet, and I would like to delete all rows whose column B does not contain one of a number of substrings. That is, if the text in column B does not have substring1, substring2, or substring3 in it, I'd like the associated row to disappear. What would be helpful in doing this? I'm hoping I don't have to resort to scripting...

Then add a column with the formula =if(or(A1="1",A1="2",A1="3"),true,false) assuming column A has the substrings and you want to delete when 1, 2 or 3. Paste down to all rows, then sort by this column and delete when true.

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Karl Sharks posted:

Is there any way, probably through an add-on, to create a shortcut for formatting part of a cell as a subscript? It gets tedious making all the subscripts by hand and I'm sure there's some better way to do this. I'm using 2010, for the record, and had found something, but it only worked for 2005 or something.

I don't think you can do this. VBA will alter the entire contents of the cell and not just the first character.

EDIT: Corrected by ShimaTetsuo below, thanks!

Old James fucked around with this message at 14:57 on Nov 6, 2012

khazar sansculotte
May 14, 2004

Old James posted:

Then add a column with the formula =if(or(A1="1",A1="2",A1="3"),true,false) assuming column A has the substrings and you want to delete when 1, 2 or 3. Paste down to all rows, then sort by this column and delete when true.

I probably should have been more specific; I'm looking for something more like =if(or(A1contains"1",A2contains"2",A2contains"3"),true,false). I'm trying to pick out the titles of people in an organization out of a giant list of all employees; there are like 12 different kinds of vice presidents, so I'd like to grab everyone who has "vice president" anywhere in their title.

edit: figured it out! I used

code:
=or(isnumber(search("string1",B1)),isnumber(search("string2",B1)),isnumber(search("string3",B1)))

khazar sansculotte fucked around with this message at 05:05 on Nov 5, 2012

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Ronald McReagan posted:

edit: figured it out! I used

code:
=or(isnumber(search("string1",B1)),isnumber(search("string2",B1)),isnumber(search("string3",B1)))

Excellent! Just in case it matters for your use there is also Find() which has the same syntax as Search() but is case sensitive.

DukAmok
Sep 21, 2006

Using drugs will kill. So be for real.

Ronald McReagan posted:

I probably should have been more specific; I'm looking for something more like =if(or(A1contains"1",A2contains"2",A2contains"3"),true,false). I'm trying to pick out the titles of people in an organization out of a giant list of all employees; there are like 12 different kinds of vice presidents, so I'd like to grab everyone who has "vice president" anywhere in their title.

edit: figured it out! I used

code:
=or(isnumber(search("string1",B1)),isnumber(search("string2",B1)),isnumber(search("string3",B1)))

This is a more general thing that I use sometimes, but when I want to find a lot of things and parse them out quickly, I use Find+Replace. Put in the term you want to find, or enough to catch it with a search, in your case maybe "vice". Then put the exact same term in the replace field, but go to more options and Format, and change the cell background to a different color. That will go through all cells and highlight cells which contain your doubled term, then you can filter or sort by color pretty quickly. Whatever algorithm is powering the Find+Replace is like 10x as fast as most looping VBA you can throw together, so for large data sets with simple finding conditions, I've found this to be pretty efficient.

ShimaTetsuo
Sep 9, 2001

Maximus Quietus

Old James posted:

I don't think you can do this. VBA will alter the entire contents of the cell and not just the first character.

You can. Each Range object holds a Characters collection, and each Character has its own Font property. For example,

Range("A1").Characters(1,1).Font.Subscript = True

will make the first character in range A1 a subscript.

How do you want to use this, though? Is it always the same character, or easily computable (like the first or last character, or all numbers but not letters, etc...)? That should be easy. If you want to manually highlight a character and have it change, I'm not sure there is an easy way to find out which character has been highlighted.

edit: actually, you can't run a macro while in "Edit" mode (for dumb design reasons), so there's no way to select some characters in a cell and use a keyboard shortcut to format them.

ShimaTetsuo fucked around with this message at 01:32 on Nov 7, 2012

mattdev
Sep 30, 2004

Gentlemen of taste, refinement, luxury.

Women want us, men want to be us.
Hey folks, I'm having issues combining rows of data based on a common cell. I have a massive 4000 row spreadsheet that looks like the first sheet on the following spreadsheet. I'm hoping to make it look like the second sheet.

https://docs.google.com/spreadsheet/ccc?key=0Am5EbI_l2pbcdDN5TjJlN2pxZlNsZVIwZHJuLU1FcEE

Basically I want the data to combine based on the "name" column. When they're merged, they need to separate the cells based on a comma. Any ideas? I'm using the latest version of Excel for Mac.

DukAmok
Sep 21, 2006

Using drugs will kill. So be for real.

mattdev posted:

Hey folks, I'm having issues combining rows of data based on a common cell. I have a massive 4000 row spreadsheet that looks like the first sheet on the following spreadsheet. I'm hoping to make it look like the second sheet.

https://docs.google.com/spreadsheet/ccc?key=0Am5EbI_l2pbcdDN5TjJlN2pxZlNsZVIwZHJuLU1FcEE

Basically I want the data to combine based on the "name" column. When they're merged, they need to separate the cells based on a comma. Any ideas? I'm using the latest version of Excel for Mac.

I think there definitely is a way to do this with VBA (I can't think of one with regular formulas but that's not my strong point really), but I'd like to clarify a few things before I write a macro for it. Are there only two columns, Entry A and B? Second, is this a thing you're going to need to do a bunch, or do you just need to extract some data/values from this one sheet?

ZerodotJander
Dec 29, 2004

Chinaman, explain!
There's probably a clever way to do it, but I would do this-

Sort by Column A, so cells that should be merged are all next to each other.

Add a column D and column E for your desired output columns. Duplicate B2 and C2 in D2 and E2.

In column D, starting from D3, use this formula and fill down: =IF(A3=A2, D2&","&TRIM(B3), TRIM(B3))

In column E, starting from E3, use this formula and fill down: =IF(A3=A2, E2&","&TRIM(C3), TRIM(C3))

This will create your desired final output in the last row for each group with the same Name field. Then you just have to filter those out. You can do that with this formula in Column F and filling down, starting from F2: =IF(A2=A3,"No","Yes")

This will put "Yes" next to the last value (with your desired outputs). Then you can just filter by Yes in that column, and you'll have what you need.

Edit: If you do this you'll end up with some extra commas, just do Find & Replace for ",," with "," a few times. You might have to trim some leading or trailing commas as well. You can adjust the IF to check for LEN(Cell)>0 before the concatenate if you want.

ZerodotJander fucked around with this message at 00:40 on Nov 13, 2012

mattdev
Sep 30, 2004

Gentlemen of taste, refinement, luxury.

Women want us, men want to be us.

DukAmok posted:

I think there definitely is a way to do this with VBA (I can't think of one with regular formulas but that's not my strong point really), but I'd like to clarify a few things before I write a macro for it. Are there only two columns, Entry A and B? Second, is this a thing you're going to need to do a bunch, or do you just need to extract some data/values from this one sheet?

37 columns, 5428 rows. I'm just doing this once in order to dump the data into the software we use.

Edit: woops, didn't see ZerodotJander's post. Let me give this a shot.

The Gripper
Sep 14, 2004
i am winner

ZerodotJander posted:

There's probably a clever way to do it, but I would do this-
There's some clever ways, but they're a ton of a hassle to do for a one-off, taking half a dozen+ intermediary steps.

I'm pretty time-rich so I made this sample of what kind of steps would be required (some may be able to be merged, creating giant godzilla functions as a result).

https://dl.dropbox.com/u/28245256/awful.xlsx

Sections are colored as:
Green: source data
Pink: unique names
Orange: row of B column items for each person. Note: these are array formulas (ctrl+shift+enter) not regular formulas, so they don't work on Google Docs and maybe not in non-Excel spreadsheet software.
Yellow: row of unique B column items for each person without 0 values (could be combined with the orange formula, but holy lord that would have made it about 1000 characters long)
Purple: concatenate horizontal row with commas, preventing leading and trailing commas (first column has a slightly differing formula to the rest).
Blue: finished.

For this to work on real-world data the orange, yellow and purple sections would need to have an arbitrarily large number of columns (enough to cover the maximum number of times a single name appears in Column A of DATA). You'd probably want to flip columns/rows as well, since actually cloning formulas properly the way I did it is tedious. Unless you have a pressing reason to do it in a formulaic way (say, repeating it often) you're much better off just brute-forcing it.

(note: spreadsheet above only deals with the first column of data, has to be repeated for the second.)

edit; nghhhh cell F1 is saved as a non-array formula, so for that cell to work you'll need to select the formula (as if editing it) and hit CTRL+SHIFT+ENTER. (source data is empty for that cell anyway, but I am OCD though not enough to actually fix the document).

The Gripper fucked around with this message at 17:22 on Nov 13, 2012

hayden.
Sep 11, 2007

here's a goat on a pig or something
This has been driving me pretty crazy. I'm trying to use SQL queries within Excel that have values passed as parameters. This is totally fine and works dandy when the SQL statement is simple enough that the ancient "Microsoft Query Editor" can, as it says, display it graphically. The only way to add paramters to a query is through MS Query Editor, and it won't allow parameters if the query is too complicated/can't be displayed graphically. It also can't display stored procedures graphically, so that isn't an option either.

You can copy/paste an existing simple, working query with paramters and try to change the query to a more complicated one, but it throws up errors like "[microsoft][odbc sql server driver]invalid parameter number".

One resource online says that you can edit the query using the "Microsoft Script Editor" (which is different from the regular VBA editor), but MS took it out of Office 2010 for reasons unknown so that isn't an option either.

Any advice? Is there some plugin out there to make my life easier?

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures

hayden. posted:

Any advice? Is there some plugin out there to make my life easier?

I've added parameters to queries too complex for the Query Editor before. The path was kinda unpleasant - I saved the spreadsheet I was working on to the 2003-era SpreadsheetML format, which has very scant documentation. You can then delve into the markup for the querytable and give it the parameters you need. The easiest thing to do is create two basic example spreadsheets to use as reference, one with a simple parametrised query and one with a complex query and no parameters, then combine them with a bit of trial and error.

Once you've got a SpreadsheetML version working, excel will happily convert it back into normal formats without it breaking - she lacks the interface to create them but not the capacity to run 'em. Just hope and pray you never need to modify it again...

I also recall a much worse trick where the query I wanted used several named subqueries, and the parameters for the query were buried in the innermost query, so you couldn't expose them without combining the whole mess into a single monster SQL statement. The way round that was to use a sql statement like:
code:
EXECUTE OuterQuery ? ?
and use the same SpreadsheetML trick to bind two parameters to the statement. I was pretty amazed it worked at all.

hayden.
Sep 11, 2007

here's a goat on a pig or something

Heavy_D posted:

You can then delve into the markup for the querytable and give it the parameters you need.

What method/tool do you use to do that?

Thanks for the response, by the way! Very helpful.

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures

hayden. posted:

What method/tool do you use to do that?
Notepad.

PokerJoe
Apr 30, 2007
Aces Low
Hi All,

I need guidance with a function that will check domains on an email distribution list vs an approved list of domains? This is for my a report build/distributor sheet I'm making for my Dad and this email check is the only step I can't do.

E.g. Each row is a client C2 has the distribution list 'joe@aaa.com; jane@bbb.com; john@bbb,com' and C3 has the approved domains for the client '@aaa.com; @bbb.com'.

I would like the sheet to know if a non approved domain has been used (e.g. jack@ccc.com), notify the user and have them confirm the entry.

I've looked online and can't see where to begin and my other two trusty vba friends aren't able to help either.

Any tips would be appreciated.

Turkeybone
Dec 9, 2006

:chef: :eng99:
I am but an amateur, but let me ponder until the big guns show up.

I'm not totally understanding how the emails and domains are organized, but I'm guessing that you'll be checking the domains either a vlookup or some looping through a range. If you just want to check stuff after the @, um I think it's some sort of use of right(thisCell,Instr(thisCell,@)) or something like that. Others can clarify Im sure.

The Gripper
Sep 14, 2004
i am winner

PokerJoe posted:

I've looked online and can't see where to begin and my other two trusty vba friends aren't able to help either.

Any tips would be appreciated.
Assuming you meant A2 is client name (or something), B2 is distribution list "dongs@boner.com; whoever@whatever.com" and B3 is "@boner.com; @google.com", you could use a function like this to at least tell you if any address in the distribution list isn't in the approved domains list:
Visual Basic .NET code:
Public Function Dongs(Dist, Approved) As Boolean
    d = Split(Dist, ";")
    a = Split(Approved, ";")
    
    status = True
    
    For Each dist_addr In d
        current_domain = "@" & Split(dist_addr, "@")(1)
        If InArray(current_domain, a) = False Then
            status = False
            Exit For
        End If
    Next dist_addr
    
    Dongs = status
End Function

Function InArray(Value, Arr) As Boolean
    If Not IsArray(Arr) Then Exit Function
    
    Dim exists As Boolean
    For Each entry In arr
        If Value = Replace(entry, " ", "") Then
            exists = True
            Exit For
        End If
    Next entry
    
    InArray = exists
End Function
and use it as =Dongs(B2,C2), to retrieve a boolean TRUE/FALSE depending on whether addresses in B2 have domains matching C2.

Shouldn't be too hard to use that to prompt the user to approve an address if necessary (after the if InArray(current_domain, a) = False Then line in Dongs(), removing the Exit For so you'll be prompted for each failure and not just the first.)

I'm pretty rusty at VBA, so apologies for the varying usages of Dim and things.

PokerJoe
Apr 30, 2007
Aces Low
Hi Gripper,

Thanks for the above. I don't 100& follow it but see enough to get me going I think.

Thanks again for taking time to look at it.

The Gripper
Sep 14, 2004
i am winner
I was going to comment it but I couldn't remember what character was used to denote comments in VBA, but the general gist of it is:
- Function Dongs(d,a) takes the values of 2 cells: the distribution list separated by semicolons, and the approved domains list also separated by semicolons.
- It splits both by the delimiter ";", so you get two arrays containing each individual email/domain.
- Loops through each address from the distribution array:
- Splits it to get the domain (and then adds a leading @ as the split removes it)
- Checks if it is in the array of approved domains using InArray.

As soon as one email from the distribution list fails the test, it returns FALSE.

PokerJoe
Apr 30, 2007
Aces Low
Hi Gripper,

Want to say thank you so much for the help. It works a treat and seriously helps with the control's in place.

Hoops
Aug 19, 2005


A Black Mark For Retarded Posting
I have a large set of data values, and I need to count the frequency of a set of equally spaced subintervals (chi-squared test for independence of random variables for any statisticians in the thread).

So for a bunch of decimals between 0 and 1, I need to count how many are less than 0.2, how many between 0.2 and 0.4, between 0.4 and 0.6, etc. There must be a very simple way of doing this but it's late and I'm tired and I can't think of it, can someone help?

edit: =COUNTIF(A1:A100;<0.2) and =FREQUENCY(A1:A100;<0.2) are the sort of thing I need to use, but it's not happy with the "<0.2" part. (btw I'm using OpenOfficeCalc not Excel.)

Hoops fucked around with this message at 23:57 on Nov 21, 2012

Ragingsheep
Nov 7, 2009
The "<0.2" part actually needs to be in quotation marks-at least on Excel

Hoops
Aug 19, 2005


A Black Mark For Retarded Posting

Ragingsheep posted:

The "<0.2" part actually needs to be in quotation marks-at least on Excel
I got it to work by doing =FREQUENCY(C$8:C$32;E7), where the C column is my data and the E column is my intervals, but only by subtracting all the columns above it (e.g =FREQUENCY(C$8:C$32;E11)-F10-F9-F8-F7). How can I make it only count the values between say, 0.6 and 0.8 in one function?

Hoops fucked around with this message at 00:10 on Nov 22, 2012

Ragingsheep
Nov 7, 2009

Hoops posted:

I got it to work by doing =FREQUENCY(C$8:C$32;E7:E11), where the C column is my data and the E column is my intervals, but only by subtracting all the columns above it. How can I make it only count the values between say, 0.6 and 0.8 in one function?

=countif(A1:A1000,"<0.8")- countif(A1:A1000,"<0.6")

Adbot
ADBOT LOVES YOU

Hoops
Aug 19, 2005


A Black Mark For Retarded Posting

Ragingsheep posted:

=countif(A1:A1000,"<0.8")- countif(A1:A1000,"<0.6")
That's so obvious. Sorry, like I said, long day. Thanks.

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