Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:14:58+00:00 2026-06-08T21:14:58+00:00

I want to sum a range from a sheet from one excel workbook and

  • 0

I want to sum a range from a sheet from one excel workbook and write it to another workbook. I came up with a following code but it is not working.

1) it opens a file open windows which asks me to select workbook to update

2) after selecting a workbook it writes “0” as a value.

Code:

Dim xl1 As New Excel.Application
Dim xl2 As New Excel.Application

Dim wb1 As Excel.Workbook
Dim wb2 As Excel.Workbook

Dim st1 As Excel.Worksheet
Dim st2 As Excel.Worksheet

wb1 = xl1.Workbooks.Open("F:\excelsumtest\file1.xlsx")
wb2 = xl2.Workbooks.Open("F:\excelsumtest\file2.xlsx")

st1 = wb1.Worksheets(1)
st2 = wb2.Worksheets(1)

st2.Cells(1, 1).formula = "=Sum(st1!A1:S1)"

Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:14:59+00:00Added an answer on June 8, 2026 at 9:14 pm

    Try changing this line:

    wb2 = xl2.Workbooks.Open("F:\excelsumtest\file2.xlsx")
    'to this:
    wb2 = xl1.Workbooks.Open("F:\excelsumtest\file2.xlsx")
    

    I’m tying both workbooks to 1 instance of an Excel application. This isn’t tested, but I think that this way, Excel will understand that it’s the worksheet from the xl1 workbook that you’re trying to insert.

    If not, you might have to fully define the workbook you’re referencing in your formula.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a formula to SUM from column B4 to M4, this
I am trying to create a dynamic range using Excel functions that will sum
The following code provides two approaches that generate pairs of integers whose sum is
In some code I want to choose n random numbers in [0,1) which sum
I need to generate 238 numbers, with a range of 1-4, but I want
I want to sum columns. In my controller def index @performance_reports = PerformanceReport.all end
I want to sum all elements of matrix in Matlab. If I had a
Crazy question...however, I want the sum of all the rows in a table for
I want to display sum of a column in a textbox when I hit
I am having a problem with my query. I want to use SUM in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.