vbscript to dynamically update the excel cell range,when source data is updated and refresh the pivot table simultaneouslySelect a range in Excel vbscriptExcel Pivot table creation through vbscriptHow to enter values in cells in Excel in a column with VBscriptProperties of a cell in Excel (used in VBScript)?Create an Excel Table in VBScriptvbscript update excel spreadsheetCreating a Pivot table with VBScriptsplit excel cell using vbscriptSelecting Excel Cells with data in VBScriptVBScript for Excel “objWorkbook.RefreshAll” doesn't refresh data

Optimize a query reducing logical reads

Gave from hunger: Imperfect past tense of "feed"?

Fix Ethernet 10/100 PoE cable with 7 out of 8 wires alive

Does the app TikTok violate trademark?

What makes learning more difficult as we age?

Problematic Nature of Views

Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?

Another student has been assigned the same MSc thesis as mine (and already defended)

How to realistically describe pain?

What would influence an alien race to map their planet in a way other than the traditional map of the Earth

Is there any exception that proves or suggests that the law of non-contradiction does not always apply?

Can you trip a breaker from a different circuit?

Create the same subfolders in another folder

Is the order of words purely based on convention?

Why is STARTTLS still used?

String whitespaces

How do my husband and I get over our fear of having another difficult baby?

Is a Middle Name a Given Name?

Assembly of PCBs containing a mix of SMT and thru-hole parts?

What in my code changed between MacTeX 2017 and MacTex 2019?

お仕事に学校頑張って meaning

MaxDetect speed

How to adjust OS print output to different screen dimensions on VIC-20?

Calculate the Ultraradical



vbscript to dynamically update the excel cell range,when source data is updated and refresh the pivot table simultaneously


Select a range in Excel vbscriptExcel Pivot table creation through vbscriptHow to enter values in cells in Excel in a column with VBscriptProperties of a cell in Excel (used in VBScript)?Create an Excel Table in VBScriptvbscript update excel spreadsheetCreating a Pivot table with VBScriptsplit excel cell using vbscriptSelecting Excel Cells with data in VBScriptVBScript for Excel “objWorkbook.RefreshAll” doesn't refresh data






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I have an excel workbook consisting of a source data and a pivot table.
the source data gets updated with new records daily along with some changes in the existing data.



I have written a vbscript in notepad and saved it with .vbs and I am calling it from Rstudio to perform the refresh pivot table action.



But,when I run this script in Rstuido :



 pathofvbscript = ("D:\Users\703225799\WIP\R\pivot\r5.vbs")
shell(shQuote(normalizePath(pathofvbscript)),"cscript",flag =
"//nologo")


I am getting the following error :



 D:Users703225799WIPRpivotr5.vbs(14, 1) Microsoft VBScript runtime 
error: Object doesn't support this property or method: 'objWB.Range'


VBS code :



 '------------------------------------------------------------------------
'Set Pivot Table & Source Worksheet
'------------------------------------------------------------------------
Set objExcel = CreateObject("Excel.Application")
Set objWB =
objExcel.Workbooks.Open("D:Users703225799WIPRpivotNew
folderBook1.xlsx")
Set Pivot_Sheet = objWB.Worksheets("pvt")

'-----------------------------------------------------------------------
'Enter in Pivot Table Name
'-----------------------------------------------------------------------
PivotName = "PivotTable1"
objWB.Activate

Set StartPoint = objWB.Range("A1")
LastCol = StartPoint.End(xlToRight).Column
DownCell = StartPoint.End(xlDown).Row
Set DataRange = Data_Sheet.Range(StartPoint, Cells(DownCell, LastCol))

New_range = objWB.Name & "!" & DataRange.Address(xlR1C1)

Pivot_Sheet.PivotTables(PivotName). _
ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(xlDatabase,NewRange)

'----------------------------------------------------------------------
'Ensure Pivot Table is Refreshed
'----------------------------------------------------------------------
Pivot_Sheet.PivotTables(PivotName).RefreshTable

'Data_Sheet.Save
'MsgBox "Your Pivot Table is now saved."

'Data_Sheet.Close
'MsgBox "Your Pivot Table is now closed."

'objExcel.Quit
'MsgBox "objExcel quit."

'----------------------------------------------------------------------
'Complete Message
'----------------------------------------------------------------------

Pivot_Sheet.Activate
MsgBox "Your Pivot Table is now updated."


objWB.Save
objWB.Close

set objExcel = Nothing
set Data_Sheet = Nothing
Set Pivot_Sheet = Nothing


Please help with the error.



Thanks,
Sayan










share|improve this question






























    -1















    I have an excel workbook consisting of a source data and a pivot table.
    the source data gets updated with new records daily along with some changes in the existing data.



    I have written a vbscript in notepad and saved it with .vbs and I am calling it from Rstudio to perform the refresh pivot table action.



    But,when I run this script in Rstuido :



     pathofvbscript = ("D:\Users\703225799\WIP\R\pivot\r5.vbs")
    shell(shQuote(normalizePath(pathofvbscript)),"cscript",flag =
    "//nologo")


    I am getting the following error :



     D:Users703225799WIPRpivotr5.vbs(14, 1) Microsoft VBScript runtime 
    error: Object doesn't support this property or method: 'objWB.Range'


    VBS code :



     '------------------------------------------------------------------------
    'Set Pivot Table & Source Worksheet
    '------------------------------------------------------------------------
    Set objExcel = CreateObject("Excel.Application")
    Set objWB =
    objExcel.Workbooks.Open("D:Users703225799WIPRpivotNew
    folderBook1.xlsx")
    Set Pivot_Sheet = objWB.Worksheets("pvt")

    '-----------------------------------------------------------------------
    'Enter in Pivot Table Name
    '-----------------------------------------------------------------------
    PivotName = "PivotTable1"
    objWB.Activate

    Set StartPoint = objWB.Range("A1")
    LastCol = StartPoint.End(xlToRight).Column
    DownCell = StartPoint.End(xlDown).Row
    Set DataRange = Data_Sheet.Range(StartPoint, Cells(DownCell, LastCol))

    New_range = objWB.Name & "!" & DataRange.Address(xlR1C1)

    Pivot_Sheet.PivotTables(PivotName). _
    ChangePivotCache ActiveWorkbook. _
    PivotCaches.Create(xlDatabase,NewRange)

    '----------------------------------------------------------------------
    'Ensure Pivot Table is Refreshed
    '----------------------------------------------------------------------
    Pivot_Sheet.PivotTables(PivotName).RefreshTable

    'Data_Sheet.Save
    'MsgBox "Your Pivot Table is now saved."

    'Data_Sheet.Close
    'MsgBox "Your Pivot Table is now closed."

    'objExcel.Quit
    'MsgBox "objExcel quit."

    '----------------------------------------------------------------------
    'Complete Message
    '----------------------------------------------------------------------

    Pivot_Sheet.Activate
    MsgBox "Your Pivot Table is now updated."


    objWB.Save
    objWB.Close

    set objExcel = Nothing
    set Data_Sheet = Nothing
    Set Pivot_Sheet = Nothing


    Please help with the error.



    Thanks,
    Sayan










    share|improve this question


























      -1












      -1








      -1


      0






      I have an excel workbook consisting of a source data and a pivot table.
      the source data gets updated with new records daily along with some changes in the existing data.



      I have written a vbscript in notepad and saved it with .vbs and I am calling it from Rstudio to perform the refresh pivot table action.



      But,when I run this script in Rstuido :



       pathofvbscript = ("D:\Users\703225799\WIP\R\pivot\r5.vbs")
      shell(shQuote(normalizePath(pathofvbscript)),"cscript",flag =
      "//nologo")


      I am getting the following error :



       D:Users703225799WIPRpivotr5.vbs(14, 1) Microsoft VBScript runtime 
      error: Object doesn't support this property or method: 'objWB.Range'


      VBS code :



       '------------------------------------------------------------------------
      'Set Pivot Table & Source Worksheet
      '------------------------------------------------------------------------
      Set objExcel = CreateObject("Excel.Application")
      Set objWB =
      objExcel.Workbooks.Open("D:Users703225799WIPRpivotNew
      folderBook1.xlsx")
      Set Pivot_Sheet = objWB.Worksheets("pvt")

      '-----------------------------------------------------------------------
      'Enter in Pivot Table Name
      '-----------------------------------------------------------------------
      PivotName = "PivotTable1"
      objWB.Activate

      Set StartPoint = objWB.Range("A1")
      LastCol = StartPoint.End(xlToRight).Column
      DownCell = StartPoint.End(xlDown).Row
      Set DataRange = Data_Sheet.Range(StartPoint, Cells(DownCell, LastCol))

      New_range = objWB.Name & "!" & DataRange.Address(xlR1C1)

      Pivot_Sheet.PivotTables(PivotName). _
      ChangePivotCache ActiveWorkbook. _
      PivotCaches.Create(xlDatabase,NewRange)

      '----------------------------------------------------------------------
      'Ensure Pivot Table is Refreshed
      '----------------------------------------------------------------------
      Pivot_Sheet.PivotTables(PivotName).RefreshTable

      'Data_Sheet.Save
      'MsgBox "Your Pivot Table is now saved."

      'Data_Sheet.Close
      'MsgBox "Your Pivot Table is now closed."

      'objExcel.Quit
      'MsgBox "objExcel quit."

      '----------------------------------------------------------------------
      'Complete Message
      '----------------------------------------------------------------------

      Pivot_Sheet.Activate
      MsgBox "Your Pivot Table is now updated."


      objWB.Save
      objWB.Close

      set objExcel = Nothing
      set Data_Sheet = Nothing
      Set Pivot_Sheet = Nothing


      Please help with the error.



      Thanks,
      Sayan










      share|improve this question














      I have an excel workbook consisting of a source data and a pivot table.
      the source data gets updated with new records daily along with some changes in the existing data.



      I have written a vbscript in notepad and saved it with .vbs and I am calling it from Rstudio to perform the refresh pivot table action.



      But,when I run this script in Rstuido :



       pathofvbscript = ("D:\Users\703225799\WIP\R\pivot\r5.vbs")
      shell(shQuote(normalizePath(pathofvbscript)),"cscript",flag =
      "//nologo")


      I am getting the following error :



       D:Users703225799WIPRpivotr5.vbs(14, 1) Microsoft VBScript runtime 
      error: Object doesn't support this property or method: 'objWB.Range'


      VBS code :



       '------------------------------------------------------------------------
      'Set Pivot Table & Source Worksheet
      '------------------------------------------------------------------------
      Set objExcel = CreateObject("Excel.Application")
      Set objWB =
      objExcel.Workbooks.Open("D:Users703225799WIPRpivotNew
      folderBook1.xlsx")
      Set Pivot_Sheet = objWB.Worksheets("pvt")

      '-----------------------------------------------------------------------
      'Enter in Pivot Table Name
      '-----------------------------------------------------------------------
      PivotName = "PivotTable1"
      objWB.Activate

      Set StartPoint = objWB.Range("A1")
      LastCol = StartPoint.End(xlToRight).Column
      DownCell = StartPoint.End(xlDown).Row
      Set DataRange = Data_Sheet.Range(StartPoint, Cells(DownCell, LastCol))

      New_range = objWB.Name & "!" & DataRange.Address(xlR1C1)

      Pivot_Sheet.PivotTables(PivotName). _
      ChangePivotCache ActiveWorkbook. _
      PivotCaches.Create(xlDatabase,NewRange)

      '----------------------------------------------------------------------
      'Ensure Pivot Table is Refreshed
      '----------------------------------------------------------------------
      Pivot_Sheet.PivotTables(PivotName).RefreshTable

      'Data_Sheet.Save
      'MsgBox "Your Pivot Table is now saved."

      'Data_Sheet.Close
      'MsgBox "Your Pivot Table is now closed."

      'objExcel.Quit
      'MsgBox "objExcel quit."

      '----------------------------------------------------------------------
      'Complete Message
      '----------------------------------------------------------------------

      Pivot_Sheet.Activate
      MsgBox "Your Pivot Table is now updated."


      objWB.Save
      objWB.Close

      set objExcel = Nothing
      set Data_Sheet = Nothing
      Set Pivot_Sheet = Nothing


      Please help with the error.



      Thanks,
      Sayan







      vbscript rstudio






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 19:03









      sayan chakrabortysayan chakraborty

      112 bronze badges




      112 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          Please try using Pivot_Sheet.Range("A1") instead of objWB.Range("A1") as the worksheet object is Pivot_sheet






          share|improve this answer

























          • Workbook Object won't support 'Range' property that's why you are getting the exception

            – Ragu
            Mar 29 at 9:44











          • I'm pretty sure it should be Data_Sheet.Range in this case.

            – Geert Bellekens
            Mar 29 at 9:47













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405101%2fvbscript-to-dynamically-update-the-excel-cell-range-when-source-data-is-updated%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          Please try using Pivot_Sheet.Range("A1") instead of objWB.Range("A1") as the worksheet object is Pivot_sheet






          share|improve this answer

























          • Workbook Object won't support 'Range' property that's why you are getting the exception

            – Ragu
            Mar 29 at 9:44











          • I'm pretty sure it should be Data_Sheet.Range in this case.

            – Geert Bellekens
            Mar 29 at 9:47















          0
















          Please try using Pivot_Sheet.Range("A1") instead of objWB.Range("A1") as the worksheet object is Pivot_sheet






          share|improve this answer

























          • Workbook Object won't support 'Range' property that's why you are getting the exception

            – Ragu
            Mar 29 at 9:44











          • I'm pretty sure it should be Data_Sheet.Range in this case.

            – Geert Bellekens
            Mar 29 at 9:47













          0














          0










          0









          Please try using Pivot_Sheet.Range("A1") instead of objWB.Range("A1") as the worksheet object is Pivot_sheet






          share|improve this answer













          Please try using Pivot_Sheet.Range("A1") instead of objWB.Range("A1") as the worksheet object is Pivot_sheet







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 29 at 9:40









          RaguRagu

          93 bronze badges




          93 bronze badges















          • Workbook Object won't support 'Range' property that's why you are getting the exception

            – Ragu
            Mar 29 at 9:44











          • I'm pretty sure it should be Data_Sheet.Range in this case.

            – Geert Bellekens
            Mar 29 at 9:47

















          • Workbook Object won't support 'Range' property that's why you are getting the exception

            – Ragu
            Mar 29 at 9:44











          • I'm pretty sure it should be Data_Sheet.Range in this case.

            – Geert Bellekens
            Mar 29 at 9:47
















          Workbook Object won't support 'Range' property that's why you are getting the exception

          – Ragu
          Mar 29 at 9:44





          Workbook Object won't support 'Range' property that's why you are getting the exception

          – Ragu
          Mar 29 at 9:44













          I'm pretty sure it should be Data_Sheet.Range in this case.

          – Geert Bellekens
          Mar 29 at 9:47





          I'm pretty sure it should be Data_Sheet.Range in this case.

          – Geert Bellekens
          Mar 29 at 9:47




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405101%2fvbscript-to-dynamically-update-the-excel-cell-range-when-source-data-is-updated%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해