Loop through range VBA

Posted on 2012-08-15
Last Modified: 2012-08-29
I am trying to use a VBA from one workbook to another.  When i run my vba it looks like my rngcell is = to nothing i need it to be the BU_Range from the BU INFO  sheet.
Can somone help me with this.  THe GXA is a global add on to Excel and should be ignored.  

Sub Update_Distribute_For_All_CBC_BU  ()
Dim rngCell As Range
Application.ScreenUpdating = False
For Each rngCell In Range("BU_RANGE")

    Range("SRF-13 Branch Income Statement Act+Bud.xlsx]Options'!$B$4") = rngCell '// change to your input cell //

            ' Add this macro to the active workbook to call Spreadsheet Server's clear cache and recalc.
             Call Application.Run("ClearAndRecalc")
             'To the active workbook to call Distribution Manager's Distribute function.
             'Distributes open file to location specified in (Options) sheet

             Call Application.Run("DistributeAll_DAS")
Next rngCell
End Sub
Question by:Jenedge73
    LVL 24

    Accepted Solution

    It may help to specify the workbook and worksheet holding the range.
    then to check the rngCell use the debug,print to view in the imediate window.

    Dim wb as workbook
    Dim ws as worksheet
    Dim rngCell As Range
    Set wb = ThisWorkbook
    set ws = wb.sheets("<insert worksheet name>")
    Application.ScreenUpdating = False
    For Each rngCell In ws.Range("BU_RANGE")
    Debug.Print rngCell.address

    Open in new window

    LVL 33

    Expert Comment

    Deleted - Misread post.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
    Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now