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
tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

Turkeybone posted:

It sounds like you'll need to use some combination of sumif/averageif to streamline your gewgaw tracking, and maybe some conditional formatting to highlight new clients vs a static list, something like that. If you are willing to sanitize a bit of your gewgaw tracker and want to send me an excel file to look at, send me a PM.

Thanks, it's really straightforward though so I don't want to waste your time with downloading it.

The sheet just looks like this:

code:
Last Name (A1) | First Name (B1) | Date 1 (C1) | Date 2 (D4 and so on) | Total gewgaws
It also doesn't matter if we have duplicates, for instance:
code:
Abeson | Abe | 2
Abeson | Abe |    | 2
Billion | Bill |   |   | 2
Is fine as long as we know that Abe Abeson has 4 gewgaws and Bill Billion only has 2.

Adbot
ADBOT LOVES YOU

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
Oh man, I just got around to testing the form entry + pivot table reporting approach and it's loving perfect. Thanks for mentioning that!

Next question, is it possible to hide a series of columns behind a password? If, for instance, I want to project a spreadsheet on a wall containing sensitive and public info, but only wanted the sensitive info displayed at certain times.

I think it's key to avoid using multiple sheets because any formulas WILL be broken the moment someone other than me touches the sheet.

Sri.Theo
Apr 16, 2008

Richard Noggin posted:

In Conditional Formatting, select "Use a formula...", then use this for the formula:
code:
=ABS($B1)>$A1
where $B1 is the first negative cell, and $A1 is the first positive cell.



That worked perfectly, thanks!

Vegetable
Oct 22, 2010

I'm working on a problem:

- Six companies are bidding on contracts for eight routes.
- Each route must have exactly one company.
- Each company is allowed at most two routes.
- We want to minimize total sum of bids (i.e. cheapest way to operate 8 routes)

This is how I've set it up. The middle table contains decision variables; the inequalities by the side indicate how I'm forcing the program to follow the above rules. The objective is some off-screen value that says "Total sum of accepted bids."



Problem, as you can see, is the program is "accepting" the 0-dollar bids (i.e. company didn't actually bid on those routes) because they're technically the cheapest. How can I set up constraints/modify my tables so it considers only the non-zero amounts in Table 1?

Max Peck
Oct 12, 2013

You know you're having a bad day when a Cylon ambush would improve it.

Vegetable posted:

Problem, as you can see, is the program is "accepting" the 0-dollar bids (i.e. company didn't actually bid on those routes) because they're technically the cheapest. How can I set up constraints/modify my tables so it considers only the non-zero amounts in Table 1?

There's probably a right way of doing it, but the laziest way I can think of doing it is making the no-bid amount an insanely large number instead, so the optimal solution should never include one, 1e100 or so.

In other words, just googol it :v:

Vegetable
Oct 22, 2010

Yeah, that's what I thought to do, but given that this is for a class, I was wondering if there's some lesson I'm supposed to be applying. A quick Google Search didn't give me much (and I'm not sure what to look for).

Wandering Orange
Sep 8, 2012

Vegetable posted:

Yeah, that's what I thought to do, but given that this is for a class, I was wondering if there's some lesson I'm supposed to be applying. A quick Google Search didn't give me much (and I'm not sure what to look for).

That sounds like a decent 'lesson' itself - you need to error-proof or otherwise filter your inputs to avoid bad data. Garbage in = Garbage out!

Anyways, what part of this are you allowed to modify or what part did you create? Can't you just ignore zero-unit bids, look for the lowest bid that is greater than zero?

Byers2142
May 5, 2011

Imagine I said something deep here...

Vegetable posted:

I'm working on a problem:

- Six companies are bidding on contracts for eight routes.
- Each route must have exactly one company.
- Each company is allowed at most two routes.
- We want to minimize total sum of bids (i.e. cheapest way to operate 8 routes)

This is how I've set it up. The middle table contains decision variables; the inequalities by the side indicate how I'm forcing the program to follow the above rules. The objective is some off-screen value that says "Total sum of accepted bids."



Problem, as you can see, is the program is "accepting" the 0-dollar bids (i.e. company didn't actually bid on those routes) because they're technically the cheapest. How can I set up constraints/modify my tables so it considers only the non-zero amounts in Table 1?

It looks like you're probably just using nested if formulae, right? if so, have the first constraint for marking a route as yes that it must be > 0. If you're not nesting formulae, paste in the formula/code that gives Company 3 Route 1, so that we can see the underlying logic.

Edit: Also, the formula/code that gave Company 6 Route 6, as it seems like it should have gone to Company 4 based on how it looks like the logic is working.

Byers2142 fucked around with this message at 02:10 on Mar 4, 2016

Vegetable
Oct 22, 2010

My bad, I should have specified. I'm actually using Excel's Solver feature.



Table 1 and 2 are as you see them. Table 3 has a formula in each cell; C26, for instance, is "C4 * C14" and so on. If I figure out how to avoid non-zero bids in other ways, I can chuck this table out. But right now I need it so I can constrain the value of any winning bid to ≥1 so it's non-zero.

There probably is a better way to do this?

Byers2142
May 5, 2011

Imagine I said something deep here...

Vegetable posted:

My bad, I should have specified. I'm actually using Excel's Solver feature.



Table 1 and 2 are as you see them. Table 3 has a formula in each cell; C26, for instance, is "C4 * C14" and so on. If I figure out how to avoid non-zero bids in other ways, I can chuck this table out. But right now I need it so I can constrain the value of any winning bid to ≥1 so it's non-zero.

There probably is a better way to do this?

I've never used the Solver feature, so I can't comment on how it works or how best to work with it. But your solution does give the right answer; if it wasn't for a class that would be good enough, but it really depends on if your teacher wants the right answer, or the right use of a specific method. My motto is if it works and doesn't take a horrible amount of time, it's better to move on to the next problem than to optimize the answer to the current one. Unless it's a fun puzzle to poke at.

If your teacher wants a specific method used, we'd need to know what subject the exercise is attached to.

khazar sansculotte
May 14, 2004

I'm having a bizarre issue, I was wondering if anyone had any insight. In a nutshell, the task is to open each file in a directory, find a file in another directory with a similar name and open it, and import data from the former file into the latter file. I'm using a standard Dir() call inside a Do While loop to loop through the directory, as I've done many times before. But for some reason, this time it always skips over the third -- and only the third -- file in my directory. Other than that it works perfectly fine. This isn't really worth the trouble of digging into very far, I can just do the leftover file by hand pretty quickly. But I was just curious if anyone could say what was going on?

edit: Fixed it. Turns out the issue was one of the file names using a Latin capital letter and the other one was using a Greek capital letter...

khazar sansculotte fucked around with this message at 21:43 on Mar 11, 2016

Squashy Nipples
Aug 18, 2007

No idea what is going on, but my guess is that the files in the folder are changing during the process?

If you want to iterate through all of the Files in a Folder, you are MUCH better off using the FileSystemObject.
Something like this:
code:
    'Specify the path to the folder
    strPath = "C:\Users\Domenic\Documents\"
    
    'Create an instance of the FileSystemObject
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    'Get the folder
    Set objFolder = objFSO.GetFolder(strPath)
    
    'If the folder does not contain files, exit the sub
    If objFolder.Files.Count = 0 Then
        MsgBox "No files were found...", vbExclamation
        Exit Sub
    End If
    
    'Loop through each file in the folder
    For Each objFile In objFolder.Files
    
        'List the name, size, and date/time of the current file
        Cells(NextRow, 1).Value = objFile.Name
        Cells(NextRow, 2).Value = objFile.Size
        Cells(NextRow, 3).Value = objFile.DateLastModified
        
        'Determine the next row
        NextRow = NextRow + 1
    
    Next objFile

Squashy Nipples
Aug 18, 2007

Ronald McReagan posted:

edit: Fixed it. Turns out the issue was one of the file names using a Latin capital letter and the other one was using a Greek capital letter...

Good catch!

I've been burned by weird file names before, and I'm sure it will happen again.

Big Bad Beetleborg
Apr 8, 2007

Things may come to those who wait...but only the things left by those who hustle.

Can this be optimised in any way?
code:
Sub GetData()

Dim SheetCount As Integer
Dim RowCount As Integer
RowCount = 4

ClearData
SetDate

For SheetCount = 2 To (ActiveWorkbook.Worksheets.Count - 1)
    
    Sheets(SheetCount).Activate
    Range("H4:M7").Select
    Selection.Copy
    ActiveWorkbook.Sheets("Index").Select
    Cells(RowCount, 2).Select
    
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
        
        RowCount = RowCount + 6
        Next SheetCount


Cells(RowCount, 4) = "Total:"
Cells(RowCount, 5) = Application.Sum(Range(Cells(1, 5), Cells(RowCount, 5)))
... which does what I want, but there seems to be a bit of a lag after it pastes each block in. Also it seems silly to have two copy/paste steps (one for calculated values, one for formatting) but I can't work out how to do that in one.

This is for generating some billing/timesheet data for month end, which pulls a few cells from each individual sheet (except last, which is a template) to an index sheet, which I'll then send off to have invoices drawn up.

Cast_No_Shadow
Jun 8, 2010

The Republic of Luna Equestria is a huge, socially progressive nation, notable for its punitive income tax rates. Its compassionate, cynical population of 714m are ruled with an iron fist by the dictatorship government, which ensures that no-one outside the party gets too rich.

Turn screen updating off and set calculation to manual (be sure to change back on and automatic at the end).

Likely to get best results.

schmagekie
Dec 2, 2003

mirthdefect posted:

Can this be optimised in any way?
code:
Sub GetData()

Dim SheetCount As Integer
Dim RowCount As Integer
RowCount = 4

ClearData
SetDate

For SheetCount = 2 To (ActiveWorkbook.Worksheets.Count - 1)
    
    Sheets(SheetCount).Activate
    Range("H4:M7").Select
    Selection.Copy
    ActiveWorkbook.Sheets("Index").Select
    Cells(RowCount, 2).Select
    
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
        
        RowCount = RowCount + 6
        Next SheetCount


Cells(RowCount, 4) = "Total:"
Cells(RowCount, 5) = Application.Sum(Range(Cells(1, 5), Cells(RowCount, 5)))
... which does what I want, but there seems to be a bit of a lag after it pastes each block in. Also it seems silly to have two copy/paste steps (one for calculated values, one for formatting) but I can't work out how to do that in one.

This is for generating some billing/timesheet data for month end, which pulls a few cells from each individual sheet (except last, which is a template) to an index sheet, which I'll then send off to have invoices drawn up.

It can be optimized a lot. You rarely need to select, activate, copy, or paste.

code:

Sub GetData()
    Dim wkb As Workbook
    Dim wks As Worksheet
    Dim wksIndex As Worksheet
    Dim RowCount As Long

    RowCount = 4
    Set wkb = ActiveWorkbook
    Set wksIndex = wkb.Sheets("Index")

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    ClearData
    SetDate

    'take H4:M7 from each sheet and put it on the index sheet
    For Each wks In wkb.Sheets
        If wks.Name <> "Index" And wks.Name <> "LastSheetName" Then 'change LastSheetName to its actual name
            wksIndex.Range(Cells(RowCount, 2), Cells(RowCount + 3, 7)).Value2 = wks.Range("H4:M7").Value2
            RowCount = RowCount + 6
        End If
    Next wks

    wksIndex.Cells(RowCount, 4) = "Total:"
    wksIndex.Cells(RowCount, 5) = Application.Sum(Range(Cells(1, 5), Cells(RowCount, 5)))

    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

End Sub

schmagekie fucked around with this message at 19:28 on Mar 15, 2016

Big Bad Beetleborg
Apr 8, 2007

Things may come to those who wait...but only the things left by those who hustle.

Oh, I thought I'd replied to this... oops.

Anyway, that worked perfectly. Thanks heaps.

Ragingsheep
Nov 7, 2009
If I have a column of IDs (there are some IDs that occur more than once) in A and a column of Age in B, how do check that if an ID is repeated, each repeat has the same age?

Edit: Also playing around with a file with ~350k rows. Any tips on how to maximise performance?

Ragingsheep fucked around with this message at 10:35 on Mar 21, 2016

TheLastManStanding
Jan 14, 2008
Mash Buttons!
Concatenate the two into a third column and check that for dupes.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Is there a way to automatically extract the coefficients from a quadratic fit into individual cells in Google Sheets? Google keeps telling me that I can do this in Excel with the linest function but I can't get this to work in Google Sheets.

e: To be more clear I have a scatter plot and added a quadratic trendline to it and it shows some equation y = ax^2 + bx + c and now I want to use this to estimate a value y if I plugged in a value x. At the moment I'm pulling the coefficients out by hand and plugging them into 3 cells in order to solve the equation but I'd like an automated way to do this.

Boris Galerkin fucked around with this message at 13:12 on Mar 22, 2016

TheLastManStanding
Jan 14, 2008
Mash Buttons!
I haven't used google sheets in depth enough to know if that function exists, but if all else fails you could calculate the quadratic regression yourself, setting aside a few cells hold the coefficients.

http://keisan.casio.com/exec/system/14059932254941

Rabbit Hill
Mar 11, 2009

God knows what lives in me in place of me.
Grimey Drawer
Hi thread. I've got an Excel question and I may not even be able to articulate it clearly! OH BOY

I have a very large (92,134 rows) spreadsheet and I want to compare data in two columns and highlight values that are different, in a particular way.

Here is a screenshot so you can see what I'm talking about :



Ideally, there should be a one-to-one correspondence between the BIBID in column A and the MFHD_ID in column C. There should not be BIBIDs that correspond to 2+ different MFHD_IDs. But of course there are! The image above shows one such case (highlighted in yellow), where BIBID 79234 has two MFHD_IDs attached, 411748 and 1131754.

I took the first step of using conditional formatting to highlight duplicates (in green) in column A, highlighting duplicates in column C, and looking for rows where there are discrepancies in highlights.

Another snapshot of another such instance, without my manual yellow highlight:



Problem rows are 94 and 95 -- same value in column A; different values in column C. (Cases like in rows 87-90 and 98-101, where the values in column A and C are duplicated in multiple rows, but are the same BIBIDs and MFHD_IDs in each row, are not a problem :toot:)

Is there a way to have Excel find and highlight the problem rows for me? So I don't have to visually scroll through 92,134 rows looking for discrepancies in highlights?? :emo:

Richard Noggin
Jun 6, 2005
Redneck By Default
Hmmm...could you keep the highlighting rules and then filter by color on MFHD_ID? This would at least show you how many problem rows you're dealing with.

fosborb
Dec 15, 2006



Chronic Good Poster
Copy A and C to a new spreadsheet, remove duplicates, and countif in a new column where A2 = A:A, A3 = A:A, etc. Anything with 2 or more means you have a one to many for that number. Now go back to your original sheet and vlookup column A to your column A on your new sheet, return the countif value and filter out anything that returns 1.

Those are your problem rows.

fosborb
Dec 15, 2006



Chronic Good Poster
Alternatively, to do this in one sheet, create a new column E:
=A2&"|"&C2.

Then in F:
= If ( countif (a:a, a2) <> countif (e:e, e2), "lovely data entry!", "OK")

And filter out your OKs.

Rabbit Hill
Mar 11, 2009

God knows what lives in me in place of me.
Grimey Drawer
Thanks for the suggestions -- I'll try them at work tomorrow, since trying to do anything with this spreadsheet on my personal laptop instantly causes the program to hang. :arghfist:

coyo7e
Aug 23, 2007

by zen death robot
Is there a way to color match in the Windows version of Excel 2016? I've found guides for the mac version, and also found instructions on how to do it in powerpoint and word however, I can't find what appears to be a similar tool in the windows version of Excel 2016.

For instance here's a guide on how to do it on a mac http://guide2office.com/1384/matching-colours-in-microsoft-office-powerpoint-word-excel/


This is kind of annoying, especially because a lot of the new color schemes in cell styles and in conditional formatting for instance, have descriptive names but, for instance, if I want to use "dark red on light red" conditional formatting style, it's really tough to match it in other cells which aren't under the conditional formatting rules as well.. I'm taking a class right now where a lot of the activities indicate to use a specific conditional formatting color scheme, and then it says "then make a cell over here, and also use that color scheme," however the only way I've really figured out how to even just match the colors from the conditional formatting styles, is to use a new conditional format rule in the different range, with the same color scheme.. IE "if this cell says 'TOTAL COSTS', then make dark red text on light red fill."

This is annoying and I'm really poor at matching colors by eye, so I'm hoping there's *some* way to do this.. I tried copying cell formatting from one cell to another however, in the case of conditionals, it just adds that conditional rule to the cell I paste the format into. Is there maybe an eyedropper tool in Excel somewhere, like there is in powerpoint?

fosborb
Dec 15, 2006



Chronic Good Poster
Press Print Screen
Open Paint, Paste
Use Eyedropper tool
Edit colors
Write down RGB values
Use RGB to select custom color in Excel

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
So, I'm trying to find duplicates from two sheets in excel.

Sheet 1 is like, 35 names and the date a test was completed for each name.

Sheet 2 is like, 40 names.

Some of the 40 names in Sheet 2 are in Sheet 1, but most of the names in Sheet 1 are not in Sheet 2 and I need a count of how many names in Sheet 2 appear in Sheet 1.

I've tried COUNTIFS, but since Sheet 2 is like:
Anna
Beryl
Charlie

And Sheet 1 is like
Anna
Abel
Angie
Bertha
Beryl
Candice

It returns a count of 1 match even though there are two matches of the sort I'm looking for. I also thought of including a SEARCH function in COUNTIFS but I think that was a foolish thing.

fosborb
Dec 15, 2006



Chronic Good Poster
Add a column to Sheet 2 and use your favorite matching function on each row.

Here's vlookup:

=VLOOKUP(Sheet2!A1,Sheet1!A:A,1,0)
=VLOOKUP(Sheet2!A2,Sheet1!A:A,1,0)
=VLOOKUP(Sheet2!A3,Sheet1!A:A,1,0)
Etc.

Sort, then count the columns that do not return an error. That's your number of names on Sheet2 that are also contained on Sheet1.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

fosborb posted:

Add a column to Sheet 2 and use your favorite matching function on each row.

Here's vlookup:

=VLOOKUP(Sheet2!A1,Sheet1!A:A,1,0)
=VLOOKUP(Sheet2!A2,Sheet1!A:A,1,0)
=VLOOKUP(Sheet2!A3,Sheet1!A:A,1,0)
Etc.

Sort, then count the columns that do not return an error. That's your number of names on Sheet2 that are also contained on Sheet1.

Oh man, that's perfect. I couldn't figure out the vlookup syntax at all. Table array and column number just didn't make any sense but now I get it. I'm not really sure I get range lookup yet though.

Squashy Nipples
Aug 18, 2007

For some reason, VLOOKUP syntax confuses the hell out of people at first. But once you get it, it makes a lot of sense.

Next learn HLOOKUP (for horizontal data), and then how to combine INDEX and MATCH (for data that is not in an orderly block).


fosborb posted:

Press Print Screen
Open Paint, Paste
Use Eyedropper tool
Edit colors
Write down RGB values
Use RGB to select custom color in Excel

My color vision is poor, and so I rely pretty heavily on this method.

Specially when any given corporate install of Office has completely different palettes installed.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe
Is there any way to use Excel as a sign in sheet in a setting where the people signing in can't comprehend a spreadsheet?

I see that Visual Basic has radio buttons so I could get them to enter their names and whether they're signing in or out and time stamp each entry, but it seems way too complex in practice.

Squashy Nipples
Aug 18, 2007

tuyop posted:

Is there any way to use Excel as a sign in sheet in a setting where the people signing in can't comprehend a spreadsheet?

I see that Visual Basic has radio buttons so I could get them to enter their names and whether they're signing in or out and time stamp each entry, but it seems way too complex in practice.

A better way is to recognize the users automatically. Someone put thought into their Exchange server names, so why not use that?

Depending on the security setup, this might ask the user for permission to access Outlook objects, so I usually just grab it once, and then store it in the registry.

code:
Sub CheckForUserName()


    'If user name is not in the registry, Get from outlook and save it
    If GetSetting("BDA", "UserData", "UserName") = Empty Then
        Application.StatusBar = "Storing Outlook user name..."
        SaveSetting "BDA", "UserData", "UserName", GetOutlookName
        Application.StatusBar = False
    End If


End Sub


Private Function GetOutlookName(Optional First_or_Last As String) As String
    
'Returns the Outlook "Current User" name as a string
'Returns full name by defualt, but user can specify "First" or "Last"
    
Dim strName As String
Dim intPara1 As Integer
Dim intPara2 As Integer
Dim intComma As Integer
    
Dim OutApp As Object
Dim OutNS As Object
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutNS = OutApp.GetNameSpace("MAPI")
    
    Let strName = OutNS.CurrentUser
    
    Set OutApp = Nothing
    Set OutNS = Nothing
    
    'Remove any Parantheticals
    Let strName = Trim(strName)
    Let intPara1 = InStr(1, strName, "(", vbTextCompare)
    If Not intPara1 = 0 Then
        Let intPara2 = InStr(1, strName, ")", vbTextCompare)
        strName = Trim(Replace(strName, Mid(strName, intPara1, intPara2 - intPara1 + 1), "", , , vbTextCompare))
    End If
    
    'if First or Last is not specified, return the whole name
    If First_or_Last = Empty Then
        GetOutlookName = strName
        Exit Function
    End If
    
    'Find comma position to split names
    Let intComma = InStr(1, strName, ",", vbTextCompare)
    
    Select Case LCase(Left(First_or_Last, 1))
        
        Case "f"
            GetOutlookName = Right(strName, Len(strName) - intComma - 1)
        
        Case "l"
            GetOutlookName = Left(strName, intComma - 1)
    
        Case Else
            GetOutlookName = strName
    
    End Select

End Function
You can put your logging routines into the ThisWorkbook Module, triggered for Workbook_Open and Workbook_BeforeClose events.

Squashy Nipples fucked around with this message at 02:19 on Apr 6, 2016

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

Squashy Nipples posted:

A better way is to recognize the users automatically. Someone put thought into their Exchange server names, so why not use that?

Depending on the security setup, this might ask the user for permission to access Outlook objects, so I usually just grab it once, and then store it in the registry.

code:
Sub CheckForUserName()


    'If user name is not in the registry, Get from outlook and save it
    If GetSetting("BDA", "UserData", "UserName") = Empty Then
        Application.StatusBar = "Storing Outlook user name..."
        SaveSetting "BDA", "UserData", "UserName", GetOutlookName
        Application.StatusBar = False
    End If


End Sub


Private Function GetOutlookName(Optional First_or_Last As String) As String
    
'Returns the Outlook "Current User" name as a string
'Returns full name by defualt, but user can specify "First" or "Last"
    
Dim strName As String
Dim intPara1 As Integer
Dim intPara2 As Integer
Dim intComma As Integer
    
Dim OutApp As Object
Dim OutNS As Object
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutNS = OutApp.GetNameSpace("MAPI")
    
    Let strName = OutNS.CurrentUser
    
    Set OutApp = Nothing
    Set OutNS = Nothing
    
    'Remove any Parantheticals
    Let strName = Trim(strName)
    Let intPara1 = InStr(1, strName, "(", vbTextCompare)
    If Not intPara1 = 0 Then
        Let intPara2 = InStr(1, strName, ")", vbTextCompare)
        strName = Trim(Replace(strName, Mid(strName, intPara1, intPara2 - intPara1 + 1), "", , , vbTextCompare))
    End If
    
    'if First or Last is not specified, return the whole name
    If First_or_Last = Empty Then
        GetOutlookName = strName
        Exit Function
    End If
    
    'Find comma position to split names
    Let intComma = InStr(1, strName, ",", vbTextCompare)
    
    Select Case LCase(Left(First_or_Last, 1))
        
        Case "f"
            GetOutlookName = Right(strName, Len(strName) - intComma - 1)
        
        Case "l"
            GetOutlookName = Left(strName, intComma - 1)
    
        Case Else
            GetOutlookName = strName
    
    End Select

End Function
You can put your logging routines into the WorkBook Module, trigger for WorkbookOpen and WorkbookBeforeClose events.

Awesome idea, but these are members of the public, they have no accounts with us.

fosborb
Dec 15, 2006



Chronic Good Poster
Why are they using your spreadsheets then? Very confused about the environment you're in.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

fosborb posted:

Why are they using your spreadsheets then? Very confused about the environment you're in.

I tried using a google form today instead but Google Drive poo poo the bed after noon and we had to go back to paper. My Luddite coworkers were very smug, especially because my manager is too passive aggressive to tell everyone that he explicitly told me to make this change.

The problem I'm trying to solve is we want to keep track of how long clients visit and how often they return, AND how long a client spends in our office when they come in. We can't just do data entry of a paper form because the clients are mostly immigrants or barely literate and their handwriting is totally illegible like 40% of the time.

My brilliant idea is to just have them type their names into a sheet that automatically counts days visited, total hours/days spent ever, and total time per day spent inside. We can't generate independent accounts for each client, but we do need to track their progress and biographical data as well (this is currently done in the most maddening way possible, entirely handwritten and counted. I'll share the flowchart I made to demonstrate to management how loving insane the system is if there's any interest). It also has to be nearly entirely automatic since the rest of the staff here have basically no computer skills and can't even wrap their heads around using the Windows key to search or ctrl+c to copy.

I've also considered like, a timesheet/employee clock-in app but I'm not sure if any have the features I'm looking for, and I know excel does, so here we are. I think a robust, offline, automated solution is possible with a VBA userform macro thing but that's where my excel understanding totally drops off, so I mean, is it possible or advisable?

I think the form just needs to have them type in their names, automatically enter a timestamp, and record whether they're coming in or out.

fosborb
Dec 15, 2006



Chronic Good Poster
Yes, it's doable. VBA let's you do pretty much anything given enough duct tape and chewing gum. No I wouldn't advise it based on what you've posted.

Do you have Access? This is pretty much the perfect use case for Access. Infrequent but multi/simultaneous user, light data entry, needs extensive guardrails. You could whip out a time clock in Access in minutes.

tuyop
Sep 15, 2006

Every second that we're not growing BASIL is a second wasted

Fun Shoe

fosborb posted:

Yes, it's doable. VBA let's you do pretty much anything given enough duct tape and chewing gum. No I wouldn't advise it based on what you've posted.

Do you have Access? This is pretty much the perfect use case for Access. Infrequent but multi/simultaneous user, light data entry, needs extensive guardrails. You could whip out a time clock in Access in minutes.

That sounds like what I thought.

Unfortunately, we don't have Access. Libreoffice Base is a possibility, but it needs to work fairly seamlessly with excel by producing a sheet with dates visited that can be matched to our master tracker workbook.

Adbot
ADBOT LOVES YOU

fosborb
Dec 15, 2006



Chronic Good Poster
Honestly a Google form is a great idea. We used it for diaper tracking with our newborn. Sounds like essentially the same requirements.

How did it poo poo the bed? I've run barebones ticketing systems for 100+ conference staff out of Google Forms without issue. You should at least give it another shot.

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