Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all 88257 articles
Browse latest View live

How to find the LAST (repetitive) value in a range using a macro? [closed]

$
0
0

For example I have the following data starting in cell 'B3' :

  1. B3 qqq
  2. B4 www
  3. B5 eee
  4. B6 qqq
  5. B7 qqq
  6. B8 rrr

I want to loop through the whole range "B:B" and find and stop at the cell address of the LAST"qqq" that is present in that range (In this case "qqq" in range "B7")


I'm getting stuck at vba runtime error 424

$
0
0

I'm getting

run-time error 424

and I don't know how to fix it.

My previous question I posted ; How to scrape specific part of online english dictionary?

My final goal is to get result like this;

    A          B
beginning   bɪˈɡɪnɪŋ
behalf      bɪˈhæf
behave      bɪˈheɪv
behaviour   bɪˈheɪvjər
belong      bɪˈlɔːŋ
below       bɪˈloʊ
bird        bɜːrd
biscuit     ˈbɪskɪt

Here's code I wrote, and it's mostly based on someone else's code I found on internet.

'   Microsoft ActiveX Data Objects x.x Library
'   Microsoft XML, v3.0
'   Microsoft VBScript Regular Expressions

Sub ParseHelp()

    ' Word reference from
    Dim Url As String
    Url = "https://www.oxfordlearnersdictionaries.com/definition/english/"& Cells(ActiveCell.Row, "B").Value

    ' Get dictionary's html
    Dim Html As String
    Html = GetHtml(Url)

    ' Check error
    If InStr(Html, "<TITLE>Not Found</Title>") > 0 Then
        MsgBox "404"
        Exit Sub
    End If

    ' Extract phonetic alphabet from HTML
    Dim wrapPattern As String
    wrapPattern = "<span class='name' (.*?)</span>"
    Set wrapCollection = FindRegexpMatch(Html, wrapPattern)
    ' MsgBox StripHtml(CStr(wrapCollection(1)))

    ' Fill phonetic alphabet into cell
    If Not wrapCollection Is Nothing Then
        Dim wrap As String

        On Error Resume Next
            wrap = StripHtml(CStr(wrapCollection(1)))
        If Err.Number <> 0 Then
            wrap = ""
        End If
        Cells(ActiveCell.Row, "C").Value = wrap
    Else
        MsgBox "not found"
    End If

End Sub

Public Function StripHtml(Html As String) As String
    Dim RegEx As New RegExp
    Dim sOut As String

    Html = Replace(Html, "</li>", vbNewLine)
    Html = Replace(Html, "&nbsp;", "")

    With RegEx
        .Global = True
        .IgnoreCase = True
        .MultiLine = True
        .Pattern = "<[^>]+>"
    End With

    sOut = RegEx.Replace(Html, "")
    StripHtml = sOut
    Set RegEx = Nothing
End Function

Public Function GetHtml(Url As String) As String
    Dim xmlhttp As Object
    Set xmlhttp = CreateObject("MSXML2.serverXMLHTTP")
    Dim converter As New ADODB.stream

    ' Get
    request.Open "GET", Url, False
    request.send

    ' raw bytes
    converter.Open
    converter.Type = adTypeBinary
    converter.Write request.responseBody

    ' read
    converter.Position = 0
    converter.Type = adTypeText
    converter.Charset = "utf-8"' close
    GetHtml = converter.ReadText
    converter.Close

End Function

Public Function FindRegexpMatch(txt As String, pat As String) As Collection
    Set FindRegexpMatch = New Collection

    Dim rx As New RegExp
    Dim matcol As MatchCollection
    Dim mat As Match
    Dim ret As String
    Dim delimiter As String

    txt = Replace(txt, Chr(10), "")
    txt = Replace(txt, Chr(13), "")

    rx.Global = True
    rx.IgnoreCase = True
    rx.MultiLine = True
    rx.Pattern = pat
    Set matcol = rx.Execute(txt)
    'MsgBox "Match:"& matcol.Count

    On Error GoTo ErrorHandler
    For Each mat In matcol
        'FindRegexpMatch.Add mat.SubMatches(0)
        FindRegexpMatch.Add mat.Value

    Next mat
    Set rx = Nothing


   ' Insert code that might generate an error here
   Exit Function
ErrorHandler:
   ' Insert code to handle the error here
   MsgBox "FindRegexpMatch. "& Err.GetException()
   Resume Next

End Function

Any kind of help would be greatly appreciated.

How to use Powershell to paste an excel table into powerpoint while keeping the formatting

$
0
0

I am trying to paste several excel tables into powerpoint using Powershell:

$shape = $slide.Shapes.PasteSpecial($ppPasteJPG,$false,$null,$null,$null,$null)

It seems to work perfectly with two of the 6 excel tables I am pasting, but with the other 4 it does not. The two it works with are .xlsm, whereas the 6 are xlsx. Why is this, and how can I make it work with all of them?

Cannot Run Visual Basic Editor Because of a Syntax error after splitting workbook into two

$
0
0

I have a VBA Excel model which I have separated into two separate workbooks: InputsWB, which contains all the inputs for the model, and RunnerWB, which contains the bulk of the VBA code (and all the class modules live here). Depending on the needs of the user, the InputsWB can either call the macro in the RunnerWB or the RunnerWB can call multiple versions of the InputsWB. The detail doesn't matter for this question but the two workbooks need to be separated.

Mysteriously, after the split I sometimes get a Run-time 1004 error with the message Cannot Run Visual Basic Editor Because of a Syntax error. If I Debug + F5 then the code runs until it encounters the next Application.Calculate.

I have seen many similar questions while recording macros, or on Application.Calculate. I think mine is related to the Application.Calculate, but those answers don't explain why this happens. Some reasons I can think off, but cannot confirm online is:

  1. There are Modules in the two workbooks with the same names (although I've changed the modules names in the InputsWB but still get the error on occasion.
  2. There are VBA functions in the two workbooks with the same names

Are there any other reasons why I could be getting these errors?

UPDATE:

I finally realised why I got this error. I am calling a macro in my RunnerWB from my InputsWB. However, there was a duplicate function declared in my RunnerWB. Usually, this would give a Compile error: ambigious name detected when the macro was initiated from ThisWorkbook. However, because it was initiated from another workbook I got the Syntax error explained above.

Outlook error when sending more than one mail: "The item has been moved or deleted"

$
0
0
for i in processed_corpus:
  for j in i:
     if j == "pricing" or j == "price" or j == "quote" or j =="quotation":
        mail.To = "abc@xyz.com"
        mail.Subject = message.Subject
        mail.Body = message.Body + "Belongs To Pricing"
        mail.Send()
        # print("Belongs to Pricing")
        # print("**************")
        # print(j)
        worksheet.write(row,col +4,"Pricing")
        ram=1
     elif j == "service" or j=="request" or j=="servicerequest":
        mail.To = "abc@xyz.com"
        mail.Subject = message.Subject
        mail.Body = message.Body + "Belongs To Service Request"
        mail.Send()
        # print("Belongs to servicerequest")
        # print("**************")
        # print(text_corpus)
        # print(j)
        worksheet.write(row, col + 4, "Service Request")
        ram=1
if(ram==0):
    #print("nothing")
    worksheet.write(row, col + 4, "Category Not Defined")
     # else:
     #    print("Belongs to nothing")
     #    print("**************")
     #    worksheet.write(row, col + 4, "Category Not Defined")

row = row + 1
message = lastHourMessages.GetNext()
wb.save("C:\\Users\\Innovation\\Desktop\\Demo_Format.xls")`

This is the error I'm getting:

Traceback (most recent call last):

File "28/11/2k19.py", line 81, in <module>
     mail.To = "abc@xyz.com"
File "venv\lib\site-packages\win32com\client\dynamic.py", line 549, in __setattr__
     self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value) 
     pywintypes.com_error: (-2147352567, 'Exception occurred.', 
         (4096, 'Microsoft Outlook', 'The item has been moved or deleted.',
                None, 0, -2147221238),
     None)

Search in an Excel Userform from an Access Database and display results in Listbox using VBA

$
0
0

I have a userform in Excel that I intend to use as a search form and has a listbox to list the result. I am using VBA. The form will search for an Account number from a table in my Access database once the search button is clicked. Aside from a Search field (TextBox), it has a search button (CommandButton) and a Listbox. My goals are to:

  1. Connect to my Access database (which has a table I am searching to) from Excel using VBA
  2. Validate the search field. If the field is empty, it will display message to enter an account number. If the entry is not among those found in the table, it will return a message that the Account Number being searched does not exist. If it search is one of the account numbers in the table, it will display the results in the Listbox

I am trying to create an excel Worksheet to place the results of my query.

  1. AcctNo is one of the headers from my MemberAccts Table in Access that I intend to make searches
  2. acctNoField is the name of the search field in my search form

The error is saying that "No value given for one or more parameters". When debugging, "rst.Open qry, cnn, adOpenKeyset, adLockOptimistic" is highlighted.

I just do not know which parameter I am missing. Sorry, I am an newbie. Doing it for a non-profit org. Help will be deeply appreciated. Here's my VBA Code:

Private Sub acctSearchBtn_Click()

Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("AcctInfo")
sh.Cells.ClearContents

    Dim cnn As New ADODB.Connection
    Dim rst As New ADODB.Recordset

    Dim qry As String, 
    Dim AcctNo As String


   If Me.acctNoField.Value = "" Then
    MsgBox "Please enter an Account Number", vbCritical
        Exit Sub

    ElseIf Me.acctNoField.Value <> qry Then

    cnn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\MasterDb.accdb"
    qry = "SELECT * FROM MembrAccts WHERE Me.acctNoField.Value= '"& AcctNo & "'"

    rst.Open qry, cnn, adOpenKeyset, adLockOptimistic

    MsgBox "The Account Number does not exists", vbCritical
Exit Sub

    Else
        MsgBox "Place Retrieve_account function here", vbCritical

 End If

rst.Close
cnn.Close

End Sub

Hyperlink to a worksheet that then filters accordingly

$
0
0

Just wondering how I can hyperlink a word to another worksheet that then is filtered to show just the section that applies to the word. I have attached an example of countries.

On sheet-1 there are a list of States(e.g Karnataka) that I would like to hyperlink to sheet-2 but once I get to sheet 2, I would like it to only show the relevant data, e.g only the rows which show Karnataka.]

If anyone can help me that would be greatly appreciated!!

Thanks in advance. Sheet-1

Sheet-2

Create an excel tournament macro for combinations of teams in pools w/constraints

$
0
0

I was looking for help in creating this macro that should solve several future problems for my beach volleybal tournament :)

I googled several different solutions on combinations calculations but I found them to be unnecessary complicated or not exactly answering my needs, therefore here I am :D

The idea is the following:

  • I start with a number of teams (let's say up to 64)

  • Depending on the number of courts that I have available I am separating these teams in a number of "pools" (as a first approach I am planning on doing it manually, so that I can also mix strong/weak teams)

  • At this point I need some help --> how to create automatically a combination of all the teams within the pool? I would like to have two contraints: no repetitions & try to avoid as much as possible the same team to play twice in a row (sometimes it is not physically possible)

The intention is to use the sheet automatically generated for each pools to insert the results and then calculate separately all the statistics.

Here you can find the idea that I had on the final "look" of the Excel sheet (I inputed manually the "desired" results for the first pool as an example).

The idea is to have all the "orange" cells to be calculated automatically through this macro, all the "grey" ones to be filled manually and all the "green" ones with a standard Excel formula.

Thanks in advance and looking for your suggestions!


How can I convert excel or word files into pdf file, merge it into one file in another location, and mail that through vba in excel [closed]

VBA SQL query saved as a string and loaded as logging back to the database with another query

$
0
0
query_executed = "SELECT p.FBN, p.Car_Number, p.Car_Title, p.Car_Type, p.Owner car_owner, p.open_closed as Car_Status, p.Car_Status as Status, p.Car_Date_Approved, p.date_submitted_for_approval, p.Expires_After as ""Car Expire"", "& _
                   "p.Site, p.Car_Lines, p.Capex, p.PO_Committed, p.PO_Invoiced, p.Cluster "& _
                   "FROM cobrarawdata.mcl_carline p "& _
                   "WHERE "& UserDefinedFilters & _
                   "AND (p.Capex > 0 OR p.PO_Committed > 0); "

I have that SQL query which is part of an excel vba used for reporting.

I have a request that we log all of the queries being executed. So I am attempting the following:

#If Mac Then
    Sql = "INSERT INTO cobrarawdata.sssr_access_logging (username, event_datetime, event_type, query_executed) VALUES('"& LCase(Environ("USER")) & "','"& Format(Now(), "MM/dd/yyyy HH:mm:ss") & "','CAR Balance Query','"& query_executed & "')"
    ExecuteSql (Sql)
#Else
    Sql = "INSERT INTO cobrarawdata.sssr_access_logging (username, event_datetime, event_type, query_executed) VALUES('"& LCase(Environ("Username")) & "','"& Format(Now(), "MM/dd/yyyy HH:mm:ss") & "','CAR Balance Query','"& query_executed & "')"
    ExecuteSql (Sql)
#End If

I am receiving an error though when I try and use the query_executed in the insert query and I haven't been able to get any amount of jockeying with double quotes to change that.

UserWarning:Slicer List extension is not supported and will be removed warn(msg).Getting this warning while working with openpyxl and pandas

$
0
0

I am working with pandas and openpyxl.

INPUT FILES

I have total three input excel files in my program. With the help of dataframes I am processing input excel files and getting a final dataframe after processing.

OUTPUT

After getting final dataframe in my program, I am writing this dataframe below an existing excel file with the help of openpyxl. This excel file contains many worksheets. Some worksheets in this excel file also contains pivot table and its related information. Dataframe is successfully appending below excel file.

**But problem is pivot table is getting destroyed while writing dataframe below excel file.**I am getting following warning during execution of my program

C:\Users\Desktop\PycharmProjects\MyProject\venv\lib\site-packages\openpyxl\worksheet\_reader.py:292: UserWarning: Slicer List extension is not supported and will be removed
      warn(msg)
  1. I am using following method to append dataframe below an existing excel sheet with the help of openpyxl-

    HELPER FUNCTION TO APPEND DATAFRAME BELOW EXCEL FILE

    def append_df_to_excel(filename, df, sheet_name='Sheet1', startrow=None, truncate_sheet=False, **to_excel_kwargs): """ Append a DataFrame [df] to existing Excel file [filename] into [sheet_name] Sheet. If [filename] doesn't exist, then this function will create it.

    Parameters:
      filename : File path or existing ExcelWriter
                 (Example: '/path/to/file.xlsx')
      df : dataframe to save to workbook
      sheet_name : Name of sheet which will contain DataFrame.
                   (default: 'Sheet1')
      startrow : upper left cell row to dump data frame.
                 Per default (startrow=None) calculate the last row
                 in the existing DF and write to the next row...
      truncate_sheet : truncate (remove and recreate) [sheet_name]
                       before writing DataFrame to Excel file
      to_excel_kwargs : arguments which will be passed to `DataFrame.to_excel()`
                        [can be dictionary]
    
    Returns: None
    """
    from openpyxl import load_workbook
    
    import pandas as pd
    
    # ignore [engine] parameter if it was passed
    if 'engine' in to_excel_kwargs:
        to_excel_kwargs.pop('engine')
    
    writer = pd.ExcelWriter(filename, engine='openpyxl', index=False, data_only = 'True')
    
    # Python 2.x: define [FileNotFoundError] exception if it doesn't exist
    try:
        FileNotFoundError
    except NameError:
        FileNotFoundError = IOError
    
    
    try:
        # try to open an existing workbook
        writer.book = load_workbook(filename)
    
        # get the last row in the existing Excel sheet
        # if it was not specified explicitly
        if startrow is None and sheet_name in writer.book.sheetnames:
            startrow = writer.book[sheet_name].max_row
    
        # truncate sheet
        if truncate_sheet and sheet_name in writer.book.sheetnames:
            # index of [sheet_name] sheet
            idx = writer.book.sheetnames.index(sheet_name)
            # remove [sheet_name]
            writer.book.remove(writer.book.worksheets[idx])
            # create an empty sheet [sheet_name] using old index
            writer.book.create_sheet(sheet_name, idx)
    
        # copy existing sheets
        writer.sheets = {ws.title:ws for ws in writer.book.worksheets}
    except FileNotFoundError:
        # file does not exist yet, we will create it
        pass
    
    if startrow is None:
        startrow = 1
    
    # write out the new sheet
    df.to_excel(writer, sheet_name, startrow=startrow, **to_excel_kwargs)
    
    # save the workbook
    writer.save()
    
  2. Following line is used to call above helper function

    path_of_existing_excel_file = C:\Users\Desktop\MyExcel.xlsx append_df_to_excel(path_of_existing_excel_file, df1, sheet_name='MY-DATA',index = False )

3.I am able to obtain desired output.The only Problem is pivot table in excel is getting destroyed. All the sheets in my excel file which contains pivot table is losing information

Here my output is useless because I lost all the information related to my pivot table.

Hope I am clear. Now I want to ask the way by which my pivot table will not destroy ? How to do so that sheets which contains pivot table will not be affected by openpyxl? Or How can write dataframe below excel sheet so that my pivot table will not getting affected?

.Paste Method does not work correctly / behaves differently than "Ctrl + v"

$
0
0

I've seen a lot of weird things happening in excel, but this is probably the weirdest.

What do I want to do?

I'm grabbing data from SAP and want to paste it into my excel sheet via vba. (There are other methods for exporting data, but this is the one I am limited to.) The data is put into the Windows-Clipboard via SAP. Afterwards it is put into the newest excel-Worksheet (see Sub importStuff and then formatted (see Sub divData) The data is delimited with pipes | and after pasting it looks like this (including the blanks):

| FOO: BAR | 360.000 |

After I Call divData it is split into two separate columns. (this how I want it to be formatted)

[SOME_ID: SOME_NAME][360.000]

But(!) sometimes the format of the numbers get screwed up and excel formats 360.000 to 360,000 = 360. This only happens for values that end in a 0. So 360.000 is formatted to 360, 312.312.001.800 would be formatted to 312.312.001,80.

I'm using a german version of Excel 14.0.7166.5000 (32-Bit). So a . is for digit grouping, a , is the decimal mark.

This my code

Sub importStuff()

dBegin = wsUeb.Range("BeginPlan")
dEnd = wsUeb.Range("EndPlan")

'lots 
'of 
'other 
'SAP-Stuff

SAP_Session.findById("wnd[0]/usr/tabsTABSTRIP_MYTAB/tabpPUSH4/ssub%_SUBSCREEN_MYTAB:ZCO_SUSAETZE_NEW:0400/ctxtP_LAYOUT").Text = "/ZL_UMSPIEXP"
    SAP_Session.findById("wnd[0]/tbar[1]/btn[8]").press
    SAP_Session.findById("wnd[0]/tbar[1]/btn[45]").press
    SAP_Session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[4,0]").Select
    SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press

    ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
    Worksheets(Worksheets.Count).Paste
    Worksheets(Worksheets.Count).Name = "Plan-Umsaetze "& dBegin & " - "& dEnd

Call divData

End Sub

Sub divData()

ActiveSheet.Columns("A:A").TextToColumns _
DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierNone, _
ConsecutiveDelimiter:=False, _
Other:=True, _
OtherChar:="|"

End Sub

Now here is what happens.

  1. I open the workbook
  2. I call importStuff
  3. I call divData afterwards, doesn't matter if it is called within importStuff or not
  4. everything is fine
  5. I call importStuff again
  6. I don't call divData at all (doesn't matter if I do)
  7. I get erroneous values

But if I just press Ctrl+v the values get inserted just fine (see 4.)).

I can't call Ctrl+v via windows shell, because the new worksheet is invisible for the actual user.

Plase help!

Sort to optimize manager assignment in excel

$
0
0

I currently have a list of employees by region, area & branch (in that order). Every row represents a branch & the number of employees that branch have.

I want to calculate how many managers I will need to manage all these branches.

I know that one manager can only manage up to 40 employees.

Additionally, the managers can only manage branches in the same region.

I am looking for a way to sort the list so that I can minimize the number of managers I will need.

Thank you

How to check if name of an cells exists (name.name)?

$
0
0

I want to write the named area in a string (and go through column D unitl last row). But if the cell is not named I get an error on "Name = wsData.Cells(i, 4).Name.Name" and code is stopping there.

I need something like, if NamedArea is nothing/empty, then do next i. Do you have an idea?

Thank you!!

    For i = 1 To LastRow

             Name = wsData.Cells(i, 4).Name.Name

        If UCase(arrData(k, j)) = UCase(Name) Then
                arrData(k, j) = arrNames(i, 1)
                x = x + 1
                k = 1
                j = 1
                i = 1

            Exit For
        End If

    Next i

Excel: Range.Cut() or Range.ClearContents() changes the ActiveWorkBook

$
0
0

I have created an application that does following things:

  1. Open workbook from path using Excel.Interop

     newwb = ExcelApp.Workbooks.Open(path,
                                         0,
                                         false,
                                         Type.Missing,
                                         Type.Missing,
                                         Type.Missing,
                                         true,
                                         Type.Missing,
                                         Type.Missing,
                                         true,
                                         false,
                                         Type.Missing,
                                         false,
                                         Type.Missing,
                                         Type.Missing);
     newwb.Activate();
    
  2. Set ScreenUpdating to false so that the user will not be aware of the active workbook.

  3. Performing some operations like Range.Cut() or Range.ClearContents() changes the active workbook back to "Book1"

I can set the active workbook back to newwb but that would be a performance overhead and I would like to know the exact reason that changes active workbook (But it doesn't trigger workbook changed event as well).

Any help or suggestion would be great.

Thanks.


Set cell value using based on cell length

$
0
0

I have this kind of product id in column D:

  • 1942-PS-M-01
  • 1942-PS-M-233
  • 1942-P-M-25
  • 1942-P-L-200

I want to set the value in column G Using the last 2/3 number in the product id value.

I tried to use formula such =MID([Product_ID],11,3) and =MID([Sample_ID],10,3), but none of this id efficient and I have to enter the formula 1 by 1 since the id is doest not have same length.

Is there any way to do so by using vba? because I have almost 20k rows of data

I have an idea like using if (len([Product_ID])<13 then =MID([Product_ID],11,3) or if (len([Product_ID])<12 then =MID([Product_ID],10,3) but doest not know how to implement this in vba

loop through merged cells in a Column to get their addresses in vba

$
0
0

I have one column. say column A, which has multiple merged cells of different ranges. for example first cell is merged from A2 to A15 whereas second merged cell ranges from A16 to A115 now i want to run through entire column to get the address of each merged cell. i have code which helps me to get the address of the only first merge cell. can anyone help me to run a loop to get these cell address?

The following is my attempt, however the code only worked for the first cell but i want it to loop through all the cells in column A.

Sub Macro()

    Dim rng As Range, rngStart As Range, rngEnd As Range

    Set rng = Range("A2")

    If rng.MergeCells Then

        Set rng = rng.MergeArea
        Set rngStart = rng.Cells(1, 1)
        Set rngEnd = rng.Cells(rng.Rows.Count, rng.Columns.Count)

        MsgBox "First Cell "& rngStart.Address & vbNewLine & "Last Cell "& rngEnd.Address

    Else

        MsgBox "Not merged area"

    End If
End Sub

Calculate the number of days between a cell and today in excel?

$
0
0

How does one calculate the number of days between a cell with a date and today?

I've tried:

=B2-TODAY() 
=(B2)-TODAY()
=(B2-TODAY()).days
etc...

and am having no luck. How do I get the difference between cell B2 and today, in number of days?

Excel (xlsx) file from GMAIL to Google Sheets - Copy As Values Not Formula Errors

$
0
0

My question is very similar to this one, except I have formulas in my excel file which means all the data ends up being #error.

Importing XLSX file from the monthly e-mail (in Gmail) to the designated Google Sheet

Recap, I get an excel by email which I need to convert to google sheet where I already have a script which runs to pull data and then upload stock values.

Everything works well except for this one source where there are formulas in the excel file.

There's a few formulas in the excel sheet but only one column (P) I really need which has the below formula in it. It looks up the stock id to another sheet that I don't have. =IF(ISERROR(VLOOKUP(A2,'W:\Stock\Stockboard.xlsx]Stock'!$B:$N,13,FALSE)),0,VLOOKUP(A2,'W:\Stock\[Stockboard.xlsx]Stock'!$B:$N,13,FALSE))

Example File

The sheet opens in excel and excel understandably has the ability to not refresh and therefore not show errors. When I manually export to csv it's also fine.

This is the code at the moment, which is the same as the original post.

  var thread = GmailApp.search("from:(email) Stock Update has:attachment",0,1)[0];
  var message = thread.getMessages()[0];
  var xlFile = message.getAttachments()[0];
  var convertedSpreadsheetId = Drive.Files.insert({mimeType: MimeType.GOOGLE_SHEETS}, xlFile).id;

  var sheet = SpreadsheetApp.openById(convertedSpreadsheetId).getSheets()[0]; // There is the data in 1st tab.
  var data = sheet.getDataRange().getValues();

  ss.getSheetByName("test").getRange(1,1,data.length, data[0].length).setValues(data);

  Drive.Files.remove(convertedSpreadsheetId); // Remove the converted file.

Please help me edit my Multiple conditional excel formula

$
0
0

could really use your help with a formula I just built. In the below image, I am trying to build conditional formulas in columns AA through AI that will select cells from B through I only if specific conditions are met, the conditions being that the cells in columns B through I fall in either the "1 to 3" or "4 to 7" buckets AND are less than or equal to 0.68 in column P (check out this screenshot):

screenshot

Using column AH which I have colored in red, you can see the formula I built:

=IF(OR(AND(I4="1 to 3 Bucket",I4="4 to 7 Bucket"), AND(P4<=0.68)),"Select","Don't Select")

I don't think the formula I built is entirely correct. For example look at row 8. Only one condition is met yet (the Food Score) yet it is selecting every column.

Could you help me edit my formula above? I want it to select cells from columns B through H only if All the conditions are met. Thanks!

Viewing all 88257 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>