Results 1 to 9 of 9

Copied data not staying in same row

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2015
    Location
    Mid-West
    MS-Off Ver
    Office365
    Posts
    19

    Copied data not staying in same row

    Hello everyone.
    I have a sheet of data that I fill and clear repeatedly. I would like to capture some of that data to a log sheet to maintain a history.
    The attached spreadsheet functions 'almost' correctly.
    The problem I am having is; if any of the cells are empty in the data it messes up the rows in the log sheet.
    This is blender code, where I have taken code from multiple sources and tried to blend them together.

    Questions:
    How do I maintain row integrity when copying data to log sheet?
    What is the purpose of the "a" in this line of code? ""LR = .Range("a" & Rows.Count).End(xlUp).Row)"" It seems like I can change it without affecting anything in the macro.

    Functions:
    Macro -When I enter the desired date, It should copy some of the data from "existing" sheet to "ExistingLog" sheet, and maintain row integrity.

    Current Code:
    Sub CpyTest()
    Dim LR As Long, i As Long
    
    dateString = Application.InputBox("Enter A Date: ")
    
    With Sheets("Existing")
        LR = .Range("a" & Rows.Count).End(xlUp).Row
        For i = 2 To LR
            If .Range("G" & i).Value = DateValue(dateString) Then
                Sheets("ExistingLog").Range("A" & Rows.Count).End(xlUp).Offset(1).Value = .Range("A" & i).Value
                Sheets("ExistingLog").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = .Range("F" & i).Value
                Sheets("ExistingLog").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = .Range("G" & i).Value
                Sheets("ExistingLog").Range("D" & Rows.Count).End(xlUp).Offset(1).Value = .Range("H" & i).Value
          
            End If
        Next i
    End With
    End Sub
    I have attached a sample spreadsheet..

    Thanks
    tosteven
    Attached Files Attached Files
    Last edited by tosteven; 11-10-2015 at 11:46 AM. Reason: misspelling in subject

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro clears data from col A and B of the existing data when copied.
    By meseret in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2015, 05:21 AM
  2. [SOLVED] When data is copied to another workbook, hyperlinks as not copied or they don't work
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2014, 06:46 AM
  3. Trying to filter data and display it on another sheet, however the data isn't fully copied
    By patrickvdveen88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2013, 12:54 PM
  4. [SOLVED] VBA copied chart keeps on pointing to original data, VBA relinking charts to nesource data
    By dastr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-25-2013, 06:58 AM
  5. Copying multiple worksheet so that copied hyperlinks link to new copied sheets
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2013, 02:37 PM
  6. [SOLVED] Copying data adds carriage return to data copied
    By extrapulp in forum Excel General
    Replies: 2
    Last Post: 10-09-2012, 01:08 PM
  7. can i convert data copied as an image into data in excel ?
    By prabhat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-01-2005, 09:06 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