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 7935321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:53:00+00:00 2026-06-03T21:53:00+00:00

I have a script that is trying to compare specific data based on a

  • 0

I have a script that is trying to compare specific data based on a tag number in the first column of an Excel spreadsheet in two different workbooks. When I am trying to access the first workbook, it works great, and I can access the data in the cell properly, with the following command:

s_WS_string = Workbooks(s_WS_Filename).Sheets(s_WS_SheetName).Range(s_WS_col & s_WS_row).Value 

Where s_WS_col and s_WS_row are defined strings in the VBA script. This command successfully retrieves data. However,

OURS_string = Workbooks("OURS.xlsx").Sheets("Sheet1").Range(s_OURS_col & s_OURS_row).Value

Does not. s_OURS_col and s_OURS_row are both strings as well. WS stands for worksheet, which is the variable worksheet being compared against the static OURS.xlsx sheet.

They are both the exact same command, being passed the exact same type of parameters, and yet one retrieves data from the cell, while the other does not. I’m in the process of replicating it in another environment for upload if it comes down to that.

The two strings are meant to be compared to each other, and if they dont match, to concatenate and output in a replicated worksheet. Based on my output, and my own debugging, I have found that it will find the value on the first spreadsheet, but on the static spreadsheet OURS.xlsx, even when it access a cell that contains the exact same data, it will remain empty, and thus be considered to not match.

Has anyone else seen this problem?

Edit 1: Clarified some problems.

Edit 2: I understand that both workbooks must be opened in order to access them in this manner, and I assure you both are opened during the running of the script.

Edit 3: I have stepped through the script up to the point where it is passing the arguments to access the values. I have checked the values in both of the cells being passed, and they do match, but one is not being pulled from the workbook properly.

  • 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-03T21:53:02+00:00Added an answer on June 3, 2026 at 9:53 pm

    There must be something wrong with at least one of your variables. I recreated your case with 2 workbooks, Book1 and Book2, and added a value in cell A1 of Sheet1 in each. The code runs fine.

    Sub TestCellValueFromWBs()
        Dim s_WS_string, Ours_string As String
        s_WS_string = Workbooks("Book1").Sheets("Sheet1").Range("a1").Value
        MsgBox s_WS_string
    
        Ours_string = Workbooks("Book2").Sheets("Sheet1").Range("a1").Value
        MsgBox Ours_string
    End Sub
    

    Step into your code (F8) and check the values of the variables and make sure they are pointing to the correct objects.

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

Sidebar

Related Questions

This is my first script, and I am trying to compare two genome files,
I have been trying to make a script that compares two images in HTML5
I have a script that I'm trying to get working. Basically, what I'm trying
I have a python script that is trying to create a directory tree dynamically
I have a script that runs every two minutes for a Tweet-getter application. In
I have been trying to compare two arrays. Using array_intersect presents no problems. When
I have a private script that I'm trying to get to run as a
I have a Perl script that's trying to set some configured DateTime and DateTime::Duration
I have an alert script that I am trying to keep from spamming me
I have a command line script that generates some HTML that I am trying

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.