Results 1 to 4 of 4

Is it possible to do a countif in VBA using a closed workbook?

Threaded View

  1. #1
    Registered User
    Join Date
    08-06-2015
    Location
    England
    MS-Off Ver
    2013
    Posts
    68

    Is it possible to do a countif in VBA using a closed workbook?

    Hi all. My current dilemma is this: I am writing a macro that will do a few things but I am stuck at having to do a countif using a range from a different workbook. Now this workbook is a binary one (xlsb not xlsx) and is password protected. It has multiple sheets as well.

    What I want to do is a countif using a value from my workbook (the one with the code in it) as the criteria and using a column from a sheet from the closed xlsb workbook for my range:

    COUNTIF(Range,Value)
    Range = column D from a sheet in the closed workbook that is password protected
    Value= cell from current open workbook

    I am using WorksheetFunction.CountIf. I only need the range, which i tried setting up but I am getting runtime error 9 "Subscript out of range". I used a range variable MyRange and tried referencing the workbook with

    Set MyRange=Workbooks("drive:\Folder1\Folder2\WorkbookName.xlsb").Worksheets("Sheet4").Range("D:D")

    So, is it possible to do a countif using this closed, password protected workbook? And if so, how do I reference the workbook?

    Thank you all
    Last edited by Sinon05; 11-04-2016 at 10:45 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Export data with two Criteria values from closed workbook to closed workbooks VBA
    By julielara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2016, 01:56 PM
  2. need vba to copy sheets from closed workbook and paste into all closed wb's
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2016, 01:25 PM
  3. =COUNTIF with a referenced closed workbook
    By benjii19 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-09-2016, 08:44 AM
  4. Update Cell Value from a Closed Workbook to Another Closed Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2014, 04:44 PM
  5. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  6. Countif in a closed workbook
    By efernandes67 in forum Excel General
    Replies: 0
    Last Post: 03-08-2012, 12:27 PM
  7. Copy One Sheet From One Closed Workbook To Another Closed WB
    By teshiburu1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2009, 11:49 AM

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