+ Reply to Thread
Results 1 to 10 of 10

IF Statement Help

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2014
    Posts
    5

    IF Statement Help

    I am looking to make a basic IF statement to copy the data in one row to another row to make and save a log of the data transferred. all based on when the data counts up in another cell.

    row a3 is the row with the data in it. cell A2 is the cell with the number counting up in it. so when cell a2 changes from 2 to 3 I want to copy row A3 and save it to another row and be able to add rows to make a sort of log file of data.

    thanks.
    excel data.jpg
    Last edited by minepanther; 06-13-2014 at 02:01 AM. Reason: addition of info

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: IF Statement Help

    Hi there,

    example workbook with desired result will be helpful...
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  3. #3
    Registered User
    Join Date
    06-13-2014
    Posts
    5

    Re: IF Statement Help

    added screenshot

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: IF Statement Help

    Quote Originally Posted by minepanther View Post
    added screenshot
    But unfortunately it won't help us to workout a formula since we cannot work with picture


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: IF Statement Help

    Please do not upload a picture of your file...rather, upload a sample of your workbook, showing what data you are working with, a few samples of your expected outcome is (manually entered is ok) and how you arrived at that. (exclude sensitive info). Pictures are pretty much impossible to edit, and no-one wants to re-type your data for you Also, not all members can upload picture files (Company firewalls and stuff)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Registered User
    Join Date
    06-13-2014
    Posts
    5

    Re: IF Statement Help

    all of the data in the worksheet is generated on a different server and the worksheet is just linked to display the data the server is generating. as the data in "A2" counts up ( the counter is also on the external server) with each change in count I need the Row "3" saved the worksheet itself I am unable to upload from here.

  7. #7
    Registered User
    Join Date
    06-13-2014
    Posts
    5

    Re: IF Statement Help

    This is what I have so far. But it copies the cell formulas to the second sheet not the data displayed by the formulas.
    Private Sub Worksheet_Change(ByVal Target As Range)
         
        If Target.Address = "$A$2" Then
            
            Sheets(1).Range("A3:I3").Copy Sheets(2).Range("B" & Sheets(2).Rows.Count).End(xlUp).Offset(1, 0)
    
        End If
         
    End Sub

  8. #8
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: IF Statement Help

    Hi there,
    If You want to copy only values, then use it in this way:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$A$2" Then
            Sheets(1).Range("A3:I3").Copy 
    Sheets(2).Range("B" & Sheets(2).Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
    End If End Sub

  9. #9
    Registered User
    Join Date
    06-13-2014
    Posts
    5

    Re: IF Statement Help

    I made a mod to the code but it worked as I needed Thanks.
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address = "$A$2" Then
            Sheets(1).Range("A3:E3").Copy
            Sheets(2).Range("B" & Sheets(2).Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
        ElseIf Target.Address = "$G$2" Then
            Sheets(1).Range("G3:K3").Copy
            Sheets(2).Range("B" & Sheets(2).Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
        End If
        
    End Sub

  10. #10
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: IF Statement Help

    You are welcome!

+ 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. compile error expected line number statement end statement
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2014, 10:12 AM
  2. VBA Compile Error : line number or label or statement or end of statement
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2013, 06:41 PM
  3. Replies: 4
    Last Post: 06-01-2012, 10:05 AM
  4. Replies: 4
    Last Post: 05-16-2012, 05:33 PM
  5. [SOLVED] Utilize a Select Case Statement in Target Intersect Statement
    By max57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2009, 08:55 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