+ Reply to Thread
Results 1 to 4 of 4

Reversing Logger Code

Hybrid View

  1. #1
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    Reversing Logger Code

    Hi there,

    I have the following sub routine which records data on row 5 (Starting from Column C) but I'm still very new to VBA so could do with some help making my system more efficient please.

    Sub Record_data()
    
    Sheets("Data").Select
    Sheets("Data").Rows("5:5").Select
    Sheets("Data").Range("B5").Activate
    Selection.Copy
    Sheets("Data").Rows("7:7").Select
    Sheets("Data").Range("B7").Activate
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Data").Rows("7:7").Select
    Sheets("Data").Range("B7").Activate
    Application.CutCopyMode = False
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    
    End Sub
    As you can see the code itself probably isn't running as smoothly as it can but the big problem is in the way it works. Everything gets cut every second and moves down a row (so the most recent recording is at the top) but I know it would be much easier for the new line every second to just occupy the next blank row each second (most recent recording at the bottom). Could somebody help me do this please?

    Kind regards,

    PercivalP

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Reversing Logger Code

    Sub Record_data()
        
        Dim NextRow As Long
        
        With Sheets("Data")
            NextRow = .Cells.Find("*", , , , 1, 2).Row + 1
            If NextRow < 8 Then NextRow = 8
            .Rows(NextRow).Value = .Rows(5).Value
        End With
        
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,274

    Re: Reversing Logger Code

    Sub Record_data2()
    With Sheets("Data").
        .Range("5:5").Copy
        .Cells(.Rows.Count,"B").End(xlUp)(2).EntireRow.PasteSpecial Paste:=xlPasteValues
    End With
    End Sub
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    Re: Reversing Logger Code

    Thank you guys, works like a charm!

+ 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. [SOLVED] Challenging Kestrel Logger Data Separation and Calculation
    By ryanclose in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-14-2017, 10:18 AM
  2. Formula in VBA code is reversing values. How is this even possible?
    By mshaneweaver in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-29-2015, 04:59 PM
  3. My error logger procedure
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2014, 02:44 PM
  4. Averaging Data Logger Output from Seconds to Minutes
    By Ben Mayo in forum Excel General
    Replies: 2
    Last Post: 11-14-2012, 02:34 PM
  5. Excel slow-query(formula) logger?
    By waylon in forum Excel General
    Replies: 1
    Last Post: 11-05-2009, 05:09 AM
  6. Code for reversing print order
    By Paul Sheppard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-15-2008, 12:03 PM
  7. Work hour logger?
    By TCR in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-03-2006, 08:10 AM

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