+ Reply to Thread
Results 1 to 2 of 2

Do Loop with If End If statement crashing- looping through column to copy adjacent cell

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    Do Loop with If End If statement crashing- looping through column to copy adjacent cell

    Hi,

    I'm trying to create an excel sheet whereby when the user changes the value of column A3 in one Worksheet "ViewResponses", excel searches Column A in another Worksheet "QuestionsDB", starting at B4, for a matching value. If it finds this value in a cell it then copies the contents of the adjacent cell in column C to a cell in "ViewResponses." This continues till all items in Column B of QuestionsDB have been checked against the value of A3.

    I created a Do..Loop with an If statement to try and get this done but it is crashing my excel.

    Please Help, code is below

    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,197

    Re: Do Loop with If End If statement crashing- looping through column to copy adjacent cel

    Hi, Auwal,

    maybe I misunderstood what you are after but wouldn´t it be faster to use Autofilter and check if any data was found and only copy the visible cells over?

    I changed the values for dataRow and outputRow as well as had a ltlle bit of code overworked (different If..End If and moved the augment of the range to check out of there. Please try this code on a copy of your workbook:

    Please Login or Register  to view this content.
    Ciao,
    Holger

    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [ code ] Your code here [ /code ] (without the spaces inside the brackets)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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