+ Reply to Thread
Results 1 to 3 of 3

Copy data and paste to another column incrementing that column to next empty cell

Hybrid View

  1. #1
    Registered User
    Join Date
    05-28-2015
    Location
    Atlanta
    MS-Off Ver
    Office 365
    Posts
    3

    Copy data and paste to another column incrementing that column to next empty cell

    Good morning,

    I have real time data that is being imported to an excel document. When that data is recorded in cell A2 it then is copied to D2. A new data point will be recorded everyday and I want to have Column D increment by 1 every time a new data point is collected. Along with having it do that. I will need it not rewrite the previous data. So I will need it to locate the next empty cell in the column and record the data in that cell.

    Example:

    Day 1: A2=395; D2=395
    Day 2: A2=386; D3=386
    Day 3: A2=109; D4=109
    And so on.

    Any help would be greatly appreciated. Below is the code I have up to now.

    Thanks,

    James

    Private Sub stamp_DataReady()
    
    On Error GoTo Data_Error
    Dim DataVal() As String
    Dim data As String
    
    While Stamp.gotData = True
      data = Stamp.GetData
      
      If data <> "" Then
        DataVal = Split(data, ",")
    
        Select Case DataVal(0)
        Case "CMD?"
           
           Row = 1
            
        Case "DATA"
            cc = countChar(data, ",")
            Row = 2
            txtStatus2 = "Data Excepted" & (Row - 1)
            If Row < 65000 Then
                For x = 1 To cc Mod 27
                Worksheets(1).Range(Chr(64 + x) & CStr(Row)).Value = ReplaceData(DataVal(x))
                Next
                Range("B2").Copy
                Range("D1").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteAll)
                D = Columns(4).SpecialCells(11).D + 1
                                     
            End If

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy data and paste to another column incrementing that column to next empty cell

    Maybe:

    Sub edens2021()
    On Error GoTo Data_Error
    Dim DataVal() As String
    Dim data As String
    
    While Stamp.gotData = True
      data = Stamp.GetData
      
      If data <> "" Then
        DataVal = Split(data, ",")
    
        Select Case DataVal(0)
        Case "CMD?"
           
           row = 1
            
        Case "DATA"
            cc = countChar(data, ",")
            row = 2
            txtStatus2 = "Data Excepted" & (row - 1)
            If row < 65000 Then
                For x = 1 To cc Mod 27
                Worksheets(1).Range(Chr(64 + x) & CStr(row)).Value = ReplaceData(DataVal(x))
                Next
                Range("B2").Copy
                Range("D" & Rows.Count).End(3)(2).PasteSpecial (xlPasteAll)
                'D = Columns(4).SpecialCells(11).D + 1
                                     
            End If
    End Sub

  3. #3
    Registered User
    Join Date
    05-28-2015
    Location
    Atlanta
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Copy data and paste to another column incrementing that column to next empty cell

    Thank you for the help. It works great but I decided to implement a table to go along with my data points. That way it will be easier to handle the data and increase with the data points. However, using the code above. It places the data at the end of the table. What changes would I need to make in order to have it place the data within the table?

+ 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. copy and paste data in another column in next empty cell
    By dilippyare in forum Excel General
    Replies: 3
    Last Post: 11-24-2014, 11:11 AM
  2. [SOLVED] Copy all cells in column that contain data & paste to first empty row of another column.
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2014, 08:45 AM
  3. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  4. Copy and paste data if row in Column N is empty.
    By Hopper in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2009, 03:25 PM
  5. Macro-Copy&Paste Fixed Data Ranges Into Last Empty Cell of Specific Column
    By hailnorm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2009, 10:15 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