Results 1 to 4 of 4

Change code when a blank cell reached

Threaded View

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    58

    Change code when a blank cell reached

    Hi,

    I have written a data extraction code here. The Cells.Find value will be taken from Cell A2, A3, A4... down. I have put "For x = 2 to 88" but data set is not 88 rows long and i do not wish to change it everytime i change row numbers. What i want to do, is that when a blank cell (Ax) is reached, i want the code to jump to the Red colored code. How would i do this? I've tried If FindValue = "" GoTo ... but i keep getting errors

    Thanks!

    p.s. this is my first time writing such a long code and I've learnt this for a week so it'll probably look messy and junky to you.


     Sub DataExtraction()
    Sheets("Sheet2").Select
    Range("A1").Activate
    For x = 2 To 88
        FindValue = Sheets("Sheet3").Cells(x, 1).Value
        Sheets("Sheet2").Select
        Cells.Find(What:=FindValue, after:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
            ActiveCell.Offset(0, -3).Select
            If IsEmpty(ActiveCell) Then
            Cells.FindNext(after:=ActiveCell).Activate
            Cells.FindNext(after:=ActiveCell).Activate
            ActiveCell.Offset(0, -3).Select
            Selection.Copy
            ActiveSheet.Next.Select
            Cells(x, 2).Select
            ActiveSheet.Paste
            Else
            Cells.FindNext(after:=ActiveCell).Activate
            Cells.FindNext(after:=ActiveCell).Activate
            ActiveCell.Offset(0, -3).Select
            Selection.Copy
            ActiveSheet.Next.Select
            Cells(x, 2).Select
            ActiveSheet.Paste
       End If
    Next x
    
    Sheets("sheet2").Select
    Range("A1").Activate
    For x = 2 To 88
        FindValue = Sheets("sheet3").Cells(x, 1).Value
        Sheets("sheet2").Select
        Cells.Find(What:=FindValue, after:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        ActiveCell.Offset(0, 15).Select
        If IsEmpty(ActiveCell) Then
        Cells.FindNext(after:=ActiveCell).Activate
        ActiveCell.Offset(0, 15).Select
        Selection.Copy
        ActiveSheet.Next.Select
        Cells(x, 3).Select
        ActiveSheet.Paste
        Else
        Selection.Copy
        ActiveSheet.Next.Select
        Cells(x, 3).Select
        ActiveSheet.Paste
        End If
    
    Next x
    
    End Sub
    Last edited by russwongg; 08-26-2014 at 11:25 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Counting number of 1s in a row until blank cell is reached.
    By wjhansen in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-23-2013, 08:00 AM
  2. Show A1 in C3, then A2 in C3, then A3 in C3 until blank cell reached on button press
    By jamiepullen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2008, 06:04 PM
  3. Stopping A Loop When A Blank Cell Is Reached
    By Aaron1978 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2006, 07:48 AM
  4. Autofill until blank cell is reached
    By uberathlete in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2005, 09:55 PM
  5. Autofill until blank cell is reached
    By uberathlete in forum Excel General
    Replies: 7
    Last Post: 11-04-2005, 01:50 PM

Tags for this Thread

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