-1

I am trying to get my program to run through 2 workbooks and 3 worksheets. to validate some numbers for me.

Sub Validate_Old_Data()

Dim DBLbrow As Double
Dim DBLAbrow As Double
Dim DBLBbrow As Double
Dim STRname As String
Dim INTcc As Integer
Dim CopyRange As Range

 DBLbrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

 Do While BDLbrow > 5

STRname = Range("B" & DBLbrow).Value
INTcc = Range("C" & DBLbrow).Value

Workbooks("Z:\Centralized Charges\Centralized Charges 2015\Forecast and Actuals\P3\Headcount Templates\P3 Centralized Charges Headcount Tracker (vs. 2015 Budget).xlsx").Activate

Worksheets(INTcc).Activate

DBLAbrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

    Do While DBLAbrow > 8

        If Range("B" & DBLAbrow).Value = STRname Then

            CopyRange = Range(DBLAbrow).Row.Copy

            Workbooks("Z:\Centralized Charges\Centralized Charges 2015\Forecast and Actuals\P3\Headcount Templates\Charges Headcount Tracker (vs. 2015 Budget).xlsm").activatae

            Worksheets(INTcc).activatae

            DBLBbrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row

            If Range("B" & DBLBbrow).Value = STRname Then

                Range(DBLbrow).Value = CopyRange

            Else

                DBLBbrow = DBLBbrow - 1

            End If

            Loop

        Else
            DBLAbrow = DBLAbrow - 1


        End If

        Loop

BDLbrow = BDLbrow - 1

End Sub

Yet I am getting an Invalid Qualifier error, can someone explain why?

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
Ori Meir
  • 51
  • 1
  • 7
  • Can you talk a little bit more about what you're trying to do with this code? Maybe narrow it down to a smaller block. – Sandy Gifford Apr 30 '15 at 14:59
  • Which line is it stopping at? – Sam Apr 30 '15 at 15:01
  • It gets stopped on the first line...I have never had this issue before. The purpose for this code is to loop through a list, find the corresponding value in spreadsheet B then return all the data i have to Spreadsheet A. – Ori Meir Apr 30 '15 at 15:06
  • 2
    Don't know if this is the problem, but you have a misspelling....your code shows "Do While BDLBrow > 5" but your variable is named 'DBLBrow'. I'd recommend using Option Explicit to avoid errors like this in the future. – OpiesDad Apr 30 '15 at 15:09
  • One thing I noticed if it is failing on the first line is you are getting cells(Rows.Count, "B"). Pretty sure, correct me if I am wrong, but cells will only take numbers. So you should change that to cells(rows.count,2) – Sam Apr 30 '15 at 15:27
  • 1
    @Sam I thought the same some time ago but not, they "learned" to take letters as well :) – Matteo NNZ Apr 30 '15 at 15:28
  • Ah fair enough. I would of checked but currently in the middle of a very large count if – Sam Apr 30 '15 at 15:32

1 Answers1

1

Compile and Run-time errors always come with highlighting where the problem is. It's enough trying to run the code to see that the compiler will select, for you, the incorrect qualifier:

enter image description here

That's Rows, not Row.

Just to add some useful "intuitive" info to this poor answer, so that you will get helped in the future for similar problems. While developing you can have (sigh) thousands of errors that usually are classified within two types (I will stick this example to VBA):

  • Compilation error: it means that "Excel doesn't understand what you're saying". For example, you use the property Row which doesn't exist; Excel doesn't understand what you mean with Row and refuses to start. Hence, the code will not even start running and you will get a white window highlighting (when possible) the "word that Excel didn't understand" so that you can fix it.
  • Run-time error: it means that "Excel does understand what you're saying, but at some point he doesn't like it." For example, you write k = 2/0; you're not using "incomprehensible things" for Excel, but when it comes the time that it has to perform the division, its stack goes in overflow and cause a run-time error. In that case, you will get a grey window with a handy botton labelled Debug: you press on it and a yellow line of code will be highlighted, that's the line where the error lies.

I'm sorry for the "poorly techical" language I used to explain this, but I preferred you getting straight to the point. If you want to go into depth into this important topic, please read this.

Community
  • 1
  • 1
Matteo NNZ
  • 11,930
  • 12
  • 52
  • 89