+ Reply to Thread
Results 1 to 2 of 2

Script in google sheet worked yesterday, but not today

  1. #1
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2021
    Posts
    313

    Script in google sheet worked yesterday, but not today

    I'm encountering an unexpected behavior with a script I'm using. It worked successfully yesterday, but today it's not functioning as expected. I've already run a debug on the code and found no apparent issues.


    The script is designed to perform the following tasks:

    Retrieve data from the "Price" sheet.
    For all other sheets, extract data only from rows starting at row 2, specifically from columns B and C.
    Subsequently, the script should insert this data into the respective sheets.

    Additionally, it should locate the last rows in these sheets where there is a date in column B, but no data present in columns H and I.

    If these conditions are met, the script should insert the data.
    Current Challenge:

    I'm puzzled as to why the script, which operated correctly yesterday, is now experiencing this issue. I've reviewed the code in detail and can't identify any apparent problems.

    Please Login or Register  to view this content.
    https://docs.google.com/spreadsheets...it?usp=sharing
    Last edited by hendrikbez; 11-06-2023 at 02:37 AM. Reason: added appscript code

  2. #2
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2021
    Posts
    313

    Re: Script in google sheet worked yesterday, but not today

    Got it to work with this code 

    function copyToAllSheets() {
      var priceSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Price");

      var sheetRanges = {
        "Centus": "B3:C3",
        "CentusBNB": "B3:C3",
        "Plus": "B2:C2",
        "Binc": "B4:C4",
        "Bincin": "B5:C5",
        "Bincpl": "B6:C6",
        "Bincru": "B7:C7",
        "Bincua": "B8:C8",
        "Bincome": "B9:C9",
        "BincomeBNB": "B9:C9"
      };

      for (var sheetName in sheetRanges) {
        var range = sheetRanges[sheetName];
        var centusSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
        var values = priceSheet.getRange(range).getValues();

        var centusLastRow = centusSheet.getLastRow();
        var centusDate = centusSheet.getRange("B" + centusLastRow).getValue();
        var centusHValue = centusSheet.getRange("H" + centusLastRow).getValue();
        var centusIValue = centusSheet.getRange("I" + centusLastRow).getValue();

        if (centusDate && !centusHValue && centusIValue === "") {
          centusSheet.getRange("H" + centusLastRow).setValue(values[0][0].replace('$', ''));
          centusSheet.getRange("H" + centusLastRow).setNumberFormat("0.00000000");
           centusSheet.getRange("H" + centusLastRow).setFontWeight("bold");
          centusSheet.getRange("I" + centusLastRow).setValue(values[0][1]);
          centusSheet.getRange("I" + centusLastRow).setNumberFormat("+0.00%;-0.00%;0.00%");
          centusSheet.getRange("I" + centusLastRow).setFontWeight("bold");
        }
      }
    }

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Google Sheet-Googile Finance-Yesterday Price
    By grcshekar in forum Excel General
    Replies: 1
    Last Post: 10-29-2020, 08:56 AM
  2. [SOLVED] Macro worked yesterday but not today?
    By Crawfinator1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2013, 07:31 AM
  3. Created a userform in VBA that worked beautifully yesterday and crashed Excel today!
    By willneal in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-31-2012, 11:47 AM
  4. VBA-Find/Replace two strings--worked yesterday but not today
    By Royzer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2012, 05:28 PM
  5. Code Worked Yesterday, Won't Work Today
    By mgaworecki in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 02-25-2009, 06:25 PM
  6. Yesterday macro worked, today it doesn't?
    By Nickster64 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2008, 12:47 PM
  7. [SOLVED] worked yesterday- doesn't work today
    By Qaspec in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2005, 01:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1