ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    VBA Hint Needed - Change Way An Existing Project Grabs Data

    IT Discussion
    5
    72
    8.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • garak0410G
      garak0410
      last edited by

      Yeah, this one will be a toughie because it won't even let me step through past a break-point with this error:
      0_1465927901497_vba12.jpg

      dafyreD 1 Reply Last reply Reply Quote 0
      • dafyreD
        dafyre @garak0410
        last edited by

        @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

        Yeah, this one will be a toughie because it won't even let me step through past a break-point with this error:
        0_1465927901497_vba12.jpg

        You may have to resort to moving the Next rCell down a few lines at the time until you find the right spot... following OPC's can be tough if it's not nicely written... (OPC = other people's code).

        1 Reply Last reply Reply Quote 1
        • garak0410G
          garak0410
          last edited by

          I've dusted off this project because, well, the time has truly come where they want the bulk of my time in development.

          So, through some suggestions and research, I have created this part of the code:

          For Each rCell In Worksheets("REPORT").Range("W2:W50")
          Debug.Print rCell.Value:
          sJob = rCell.Value

          It grabs the data I want it to grab in column W.

          Shortly after that, it kicks off a function that is in this block of code:

          vJobFolders = Split(FindJobDir(strpathtofile & sJob), ",")
          For i = 0 To UBound(vJobFolders)

          And that function, called FindJobDir, looks like this:

          Function FindJobDir(ByVal strPath As String) As String
          Dim sResult As String

          sResult = Dir(strPath & "*", vbDirectory)
          FindJobDir = UCase$(sResult)
          Do While sResult <> ""
          sResult = Dir
          If Len(sResult) > 0 Then FindJobDir = FindJobDir & "," & UCase$(sResult)
          Loop
          End Function

          Now, this works fine as long as there is data in Column W but once it is null or empty, it proceed to pull ALL jobs from the path/directory.

          What I need it to do, is somewhere, tell it to stop once there is no more data (null/empty cell) in the Column W range...any suggestions?

          1 Reply Last reply Reply Quote 0
          • dafyreD
            dafyre
            last edited by dafyre

            if rCell.value = "" or rCell.value is null then end ?

            edit: Right above or below sJob = rCell.value ?

            garak0410G 1 Reply Last reply Reply Quote 0
            • garak0410G
              garak0410 @dafyre
              last edited by

              @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

              if rCell.value = "" or rCell.value is null then end ?

              Let me give it a shot... 🎬

              garak0410G 1 Reply Last reply Reply Quote 0
              • garak0410G
                garak0410 @garak0410
                last edited by

                @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                if rCell.value = "" or rCell.value is null then end ?

                Let me give it a shot... 🎬

                Interesting...I now get a NEXT without a FOR error...on this line:
                Next rCell
                Sheets("REPORT").Select

                dafyreD 1 Reply Last reply Reply Quote 0
                • dafyreD
                  dafyre @garak0410
                  last edited by dafyre

                  @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                  @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                  @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                  if rCell.value = "" or rCell.value is null then end ?

                  Let me give it a shot... 🎬

                  Interesting...I now get a NEXT without a FOR error...on this line:
                  Next rCell
                  Sheets("REPORT").Select

                  Make sure that if statement is all on one line? ... or change it from :

                  then end

                  to

                  then exit

                  garak0410G 1 Reply Last reply Reply Quote 0
                  • garak0410G
                    garak0410 @dafyre
                    last edited by

                    @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                    @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                    @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                    @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                    if rCell.value = "" or rCell.value is null then end ?

                    Let me give it a shot... 🎬

                    Interesting...I now get a NEXT without a FOR error...on this line:
                    Next rCell
                    Sheets("REPORT").Select

                    Make sure that if statement is all on one line? ... or change it from :

                    then end

                    to

                    then exit

                    Man, I feel I'm close here but funny how it leads to other errors...if I change to EXIT (rather then END), I get:

                    0_1469539692067_platebar02.jpg

                    dafyreD 1 Reply Last reply Reply Quote 0
                    • dafyreD
                      dafyre @garak0410
                      last edited by

                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                      @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                      @dafyre said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                      if rCell.value = "" or rCell.value is null then end ?

                      Let me give it a shot... 🎬

                      Interesting...I now get a NEXT without a FOR error...on this line:
                      Next rCell
                      Sheets("REPORT").Select

                      Make sure that if statement is all on one line? ... or change it from :

                      then end

                      to

                      then exit

                      Man, I feel I'm close here but funny how it leads to other errors...if I change to EXIT (rather then END), I get:

                      0_1469539692067_platebar02.jpg

                      Sorry... I haven't done much with VBA in a while... the semantics are different...
                      change "exit"

                      to "exit function"

                      1 Reply Last reply Reply Quote 0
                      • garak0410G
                        garak0410
                        last edited by

                        I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                        garak0410G 1 Reply Last reply Reply Quote 0
                        • garak0410G
                          garak0410 @garak0410
                          last edited by

                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                          I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                          It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                          garak0410G thwrT 2 Replies Last reply Reply Quote 0
                          • garak0410G
                            garak0410 @garak0410
                            last edited by

                            @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                            @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                            I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                            It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                            It looks like it needs a loop to do a "Do Until"...this sheet is full of loops...LOL

                            1 Reply Last reply Reply Quote 0
                            • thwrT
                              thwr @garak0410
                              last edited by

                              @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                              @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                              I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                              It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                              You mean like when the cell is empty?

                              garak0410G 1 Reply Last reply Reply Quote 0
                              • garak0410G
                                garak0410 @thwr
                                last edited by

                                @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                You mean like when the cell is empty?

                                Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                thwrT 1 Reply Last reply Reply Quote 0
                                • thwrT
                                  thwr @garak0410
                                  last edited by thwr

                                  @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                  @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                  @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                  @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                  I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                  It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                  You mean like when the cell is empty?

                                  Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                  If ActiveCell.Value = vbNullString
                                  

                                  ActiveCell is not very good, because you need to move the focus around which causes much CPU load. Just test for vbNullString, that's a predefined constant.

                                  http://stackoverflow.com/questions/13360651/excel-how-to-check-if-a-cell-is-empty-with-vba

                                  garak0410G 1 Reply Last reply Reply Quote 0
                                  • garak0410G
                                    garak0410 @thwr
                                    last edited by

                                    @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                    @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                    @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                    @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                    @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                    I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                    It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                    You mean like when the cell is empty?

                                    Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                    If ActiveCell.Value = vbNullString
                                    http://stackoverflow.com/questions/13360651/excel-how-to-check-if-a-cell-is-empty-with-vba

                                    Great...will see what happens...

                                    thwrT 1 Reply Last reply Reply Quote 0
                                    • thwrT
                                      thwr @garak0410
                                      last edited by

                                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                      I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                      It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                      You mean like when the cell is empty?

                                      Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                      If ActiveCell.Value = vbNullString
                                      http://stackoverflow.com/questions/13360651/excel-how-to-check-if-a-cell-is-empty-with-vba

                                      Great...will see what happens...

                                      Don't blame me in case of a nuclear meltdown 😉

                                      garak0410G 1 Reply Last reply Reply Quote 0
                                      • garak0410G
                                        garak0410 @thwr
                                        last edited by

                                        @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                        I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                        It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                        You mean like when the cell is empty?

                                        Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                        If ActiveCell.Value = vbNullString
                                        http://stackoverflow.com/questions/13360651/excel-how-to-check-if-a-cell-is-empty-with-vba

                                        Great...will see what happens...

                                        Don't blame me in case of a nuclear meltdown 😉

                                        Never...just jump into a lead lined Fridge before I begin... 🙂

                                        dafyreD 1 Reply Last reply Reply Quote 2
                                        • dafyreD
                                          dafyre @garak0410
                                          last edited by

                                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @thwr said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          @garak0410 said in VBA Hint Needed - Change Way An Existing Project Grabs Data:

                                          I am going to examine the code on the existing project that grabs this same data by date range and a list from another spreadsheet. Will see how it stops its data collection to complete the macro.

                                          It has a "Do Until" statement that keeps getting those job numbers until the date range is exceeded...wondering if I can DO UNTIL "null"?

                                          You mean like when the cell is empty?

                                          Yes...Do Until cell is empty...unless I am just thinking too hard on this...

                                          If ActiveCell.Value = vbNullString
                                          http://stackoverflow.com/questions/13360651/excel-how-to-check-if-a-cell-is-empty-with-vba

                                          Great...will see what happens...

                                          Don't blame me in case of a nuclear meltdown 😉

                                          Never...just jump into a lead lined Fridge before I begin... 🙂

                                          *holds door open for every one to enter... passes out helmets to everyone as they pass by.

                                          1 Reply Last reply Reply Quote 1
                                          • dafyreD
                                            dafyre
                                            last edited by

                                            Do Until would work fine, but you'd just have to remember to increment the row number each time...

                                            cellColumn="W"
                                            cellRow=1
                                            do 
                                              rCell=Sheet1.Cell(cellColumn+cellRow)
                                              rem do other stuff here over many many lines
                                              rem keep doing stuff until it's done...
                                              cellRow=cellRow+1
                                            until (rCell.value="" or rCell.value is null) 
                                            
                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 1 / 4
                                            • First post
                                              Last post