+ Reply to Thread
Results 1 to 2 of 2

Loop - if cell value in activeworkbook > cell value in thisworkbook

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    USA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    351

    Loop - if cell value in activeworkbook > cell value in thisworkbook

    I need to compare a list in ThisWorkbook to a list in another workbook, and delete the row from the other workbook if the number in the other workbook is > the number in ThisWorkbook. I'll call ThisWorkbook Workbook A, and the other workbook Workbook B for explanation purposes. Workbook A contains my code. In Workbook A is a list of filenames in column A: examples - 35, 43, 46, 60 etc...the filename is a number. These filenames, for purposes of my loop, are Workbook B, and are saved on our network. Workbook A also has a list of numbers next to each filename in column B. B1 corresponds with A1, B2 corresponds with A2 etc. Workbook A loops through each filename, opens each file, and performs a few procedures to get the files in a workable format. When done, I'm left with a column of numbers in Workbook B. I need to loop through each cell in column F of Workbook B, and check if the number in the cell is > the corresponding number contained in column B of Workbook A for the given file in the loop.

    Below is what I've been working on. As you see, I've hard-coded the number 36 into my statement, however, I can't hard-code this because this number will vary depending on which file out of 150 files the loop is working on. Any suggestions on how to go about this? If you'd like me to set up a couple sample workbooks to make it easier to understand, I can do so, please let me know. Thanks for looking!

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Loop - if cell value in activeworkbook > cell value in thisworkbook

    Hi, VBA FTW,

    that may only be the part of a loop inside another loop for all cells to work through in ThisWorkbook (Workbook A). So depending on which kiond of loop you use you may refer to rngCell.Row or lngCounter if taking the value from Workbook A. Another question could be why not use an Autofilter to compare and check if any rows are displayed to be deleted.

    A word on qualifying the contents: please do it for all ranges.

    This code will work on the ActiveSheet
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy from Array in ActiveWorkbook to ThisWorkbook; Transpose copy, Offset Paste
    By sbradley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2013, 05:17 PM
  2. using activeworkbook and thisworkbook.
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2009, 10:41 AM
  3. [SOLVED] ThisWorkbook/ActiveWorkbook
    By John Keith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2006, 06:35 PM
  4. ThisWorkbook vs. ActiveWorkbook?
    By JK in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2005, 03:06 AM
  5. Populating a listbox will a certain cell on multiple worksheets in the activeworkbook
    By KimberlyC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2005, 09:06 PM

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