I need help with vba coding to properly create an entry form that inputs data to a master table

Bobby Lichenstein 0 Reputation points
2025-01-23T17:20:12.2033333+00:00

In microsoft excel, I have a ws titled "ENTRY". On this ws, I have several inputs one of which is "LINE ITEMS" that asks for a quantity between 1-20. Depending on this input, the amount of rows the entry data will be is assigned into an entry chart. I then would like an "ENTER" or "SUBMIT" button assigned to a macro that will copy this dynamic entry chart of various amounts of rows and add it to the bottom of a master chart on another worksheet entitled "TRACKER". Once this has been input into the Tracker master chart, I would like to delete all inputs on the ENTRY ws to allow for new entries. I have this some of the way there but one issue is I cannot select just the amount of data decided by the number of line items assigned. I also do not know how to paste it with just values (no formatting).

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,111 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,182 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Barry Schwarz 3,326 Reputation points
    2025-01-27T06:55:39.8033333+00:00

    Assuming the quantity is in cell C3 and the data is in cells C4, C5, ..., there are two easy ways to select the data:

    1 - Use the End function to select the rows containing data.

    Dim Data as Range
    Set Data = Range("C4").Offset(Range("C3").value,0)
    Set Data = Range(Range("C4"),Data)
    Dim Data As Range
    Set Data = Range("c4").End(xlDown)
    Set Data = Range(Range("C4"), Data)
    Data.Select
    
    

    2 - Use the Offset function to select the specified number of rows.

    Dim Data As Range
    Set Data = Range("c4").Offset(Range("C3").Value, 0)
    Set Data = Range(Range("C4"), Data)
    Data.Select
    

    Method 1 stops at the first blank row.

    The easiest way to copy and paste the data with the options you want is to record a "temporary" macro while performing the task manually. Then you can copy (and tweak) the code into your "permanent" macro.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.