+ Reply to Thread
Results 1 to 8 of 8

VBA assistance for copy and paste-special values into specific cells and only blank rows

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    55

    VBA assistance for copy and paste-special values into specific cells and only blank rows

    Please see attached sample/test file.
    Using Office 365 Excel

    I recorded a macro (which is the only way I know how to get VBA code).

    This macro is then assigned to the button at the top of tab "Log" (says "ONLY Press..."). I do want to keep the button to execute this code.

    When this button is pressed here's what I'm trying to get it to do:
    1. Do not RUN/UPDATE anything if there aren't any blank records in Columns K & L (K & L will always have data whereas columns L-AN may or may not have data). Warn and tell the user with a pop-up that nothing was updated. Give user a button to click OK to close this pop-up window.
    2. The User will input a date range (can be the same date) into cells C1-C2. This will refresh a query on the tab "DataLookup" which will load the data that will be needed for the tab "Log".
    3. The User will then input a few records (could be 1 record, could be 5 or more, but normal is none or 1-3 per day) into the next empty row on the table (tbl_Log) found on the tab "Log". I've input "9" and "10" in column A to simulate 2 entries a user might do.
    4. Once the user has input the info in the blue section (Columns A-I), they will then press the BUTTON at the top (shown in Columns J-M)
    5. This button will then do the following...

    As mentioned above, it may do nothing and tell the user nothing was updated (i.e. say the user hits the button but hasn't added any new records).
    In most cases, the user will correctly make a new entry (like 9 & 10 in Column A in this example) and when they press this macro button...

    a. The vlookup formulas on tab "Lists" in Cells Q9-AT9 (which is also a named range called "rng_Vlookups") will be copied into all empty rows where Column K is empty on tab "Log".
    [On the tab "Lists", cell S4, I have a basic formula to count the # of empty cells and therefore the # of rows that the vlookup formulas need to be copied into, in this case it would be copied to cells K14-AN15. I was thinking that this simple count could somehow be used to determine how many rows/records are needed for the vlookup formulas to be copied?]
    b. Once copied, the macro will then do a Copy>Paste-Special Values so that the data pulled into cells K14-AN15 will be hard-coded.
    c. Then I need the macro to hit "ESC" to get out of Copy/Paste mode (so that the cells are no longer highlighted/encapsulated by the dash lines)
    d. Then have the macro hit "Home" so that the user is returned to the far left side of the screen (doesn't matter to me if they end up on row 14 or 15 or 16, just as long as we throw them to the far left so it's basically ready for new entries tomorrow.
    e. If you can tell the user how many records had data imported that would be great.

    You CAN press the button to see at least what I'm attempting to have done.

    Appreciate any assistance with how to make this work efficiently!!!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    This is somewhat confusing.

    Rather than tell us how you propose to do stuff show us exactly what you start with, what your user may add and explain all variations/permutations, then show us what you expect to see as a result.

    This seems like a simple filtering exercise rather than needing to use a VLOOKUP.
    Bear in mind that if incremental additions are needed, (and I'm not sure if that's the case here) to move new data that's been added to a database to some other sheet, it's sometimes better to erase everything you've previously added and output a complete new subset of data.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    55

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Sorry this is confusing. It's difficult to explain every detail and how we use this data.

    But I'll try to expand a bit more.

    Old way:
    User would manually input all data elements. Literally everything we want to track and then report on would be manually entered.

    New way/goal of this:
    User would input value into Column A (along with some manual notes and other entries into Columns B-I).
    But now I want to pull in the additional data and not manually add it. Pulling it in, from another query, then hard-code it so the query on the tab "DataLookup" doesn't get too large (because it could contain 100,000 or more rows and with 30 columns of vlookups Excel gets too slow (so hard-code it and save the data static on the day we log an error).

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Sorry but I can't yet visualise what you expect to SEE.

    I don't understand what you mean with terminology like 'pull in additional data', 'pulling it in from another query.'

    Neither do I see any VLOOKUP formulae. Please explain EXACTLY what you mean by additional data and another query by referencing specific cells.

    I'm assuming that the essential task is to be able to output a subset of records from the Log Sheet to the Data Lookup sheet. If so the question is how would the system know which are the new rows on the Log Sheet without marking them in some way? I see you have two date cells C1 & C2. Are these relevant to the data you want to extract?

    If the criteria for extracting to the Data Lookup sheet is the absence of a value in column K, L or both then just use an Advanced Filter to extract the relevant rows, first clearing what was there before, and if those rows contain formulae then after the filter just convert the rows to values.

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    55

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Additional data pulls from the tab "DataLookup" which is refreshed by the Start (cell C1) and End (cell C2) dates found on the Log tab. When these change the DataLookup tab refreshes to pull in the various data attributes from our internal table/warehouse. I then need to pull this data over to the Log when a user input their Value into Column A. DataLookup will have, on average, 200-400 records per day when refreshed. User will only input 0, 1 maybe 5 records per day where an error was discovered from a completely separate report. They log the Application# (in column A on tab "Log", make some notes, and the vlookups copy into Columns K-AN and then we hard-copy/paste-special the values so these values are stored forever (because the next day the DataLookup tab will pull in the next business days' activitiy).

    Vlookups are in the tab "Lists" and have a named range called "rng_Vlookups". There are 30 vlookup formulas found in cells Q9-AT9 that are 1 in the same as the named range "rng_Vlookups". These are the fomulas I'm looking to copy over to the tab "Log", into new rows, Column K-AN.

    New rows are manually added each day by a human from another report/file (not contained within this file), The user puts these on the tab "Log" by adding in row 14 for example the "9" in Column A. Then "10" in row 15 and so on. These aren't the real numbers of course.

    I'm not looking to clear anything, this is a running log.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Can we get back to basics.

    1. Is the object to identify records on the Log sheet which are blank in column K and copy the VALUES of those rows to the Data Lookup sheet?

    2. In addition there seems to be a requirement to use predetermined formula on the Lists sheet and copy those to as many rows on the Log sheet where Column K is blank? Is that the case?

    3. If the answer to 2 is Yes, are the rows that have been added always blank in column K starting with the first blank cell, or are some already complete and hence don't need copying.

    4. The formula on the Lists sheet Q9:AT9 don't have a consistent Vlookup offset. Is there any reason why these formulae can't be reordered so that the offset is consistent for all columns. i.e. just like the offsets in AC9:AT9 progress from 12 to 29, why can't Q9:AB9 be ordered in a natural order from 2:11. Incidentally you don't need to change the range being looked up each time, just specify the whole Table A2:ACnn.

    5. Better still why use Vlookups at all. You could simply make each formula a link to appropriate column in row 2 of the DataLookup sheet and then have the macro copy that down as necessary.
    For instance Q9 would be =DataLookup!B2
    R9 would be =DataLookup!B11

    ..etc

  7. #7
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    55

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Sounds good. Back to basics:
    1. The object is to copy the vlookup formulas (from tab "Lists", cells Q9-AT9, also a defined named range "rng_Vlookups") into the blank rows starting at column K on tab "Log" so that the data from tab "DataLookup" will be LOOKED UP and shown on the Log tab and then that recently copied data can be pasted-special-values to save it forever without the need to have vlookup formulas sitting there. The DataLookup tab will change what data is available is the reason we need to hard-copy and save the data without the vlookup formulas.
    2. That is correct
    3. Newly added rows: the user manually inputs data in a new row starting in Column A and doesn't go past Column I. Column K will always be blank before we copy/paste in the data. Column K will NOT always be the first blank column in the data set (for example, in my attached sample file column F, G, H and I can be blank at any time). But Column K will always be our starting point to copy in the Vlookup formulas.
    4. I'm no good with the Offset function. I can only say that the formulas in Q9:AT9 work just fine, refer to the tbl_Log and the Column Headings, and pull the position number correctly as I have them setup. I'm assuming you or someone may have a better way to do this, but I'm a novice at all of this so I'm currently using/doing what I know
    5. Keep in mind this is just a sample/test file. The tab "DataLookup" is refreshed each morning with a new set of data containing 100's or 1000's of rows. The lookup cell will move. I'm only aware of using Vlookup to find the appropriate match.

    I'll add a bit more info: New rows/entries start in Column A. The Log tab is a table called "tbl_Log" so when the user inputs a New Entry into cell A14 for example (which I've input the entry already as "9" in Cell A14 just for this test so you can see the empty cells K14:AN14). New entries cause the table to automatically grow. If you were to input "11" into cell A16 for example, the table "tbl_Log" would "grow" by 1 row and now have cells K16:AN16 needing data copied in too. Add 11 for fun and now we have 3 new entries...9, 10, and 11. It's these 3 new entries that I need the vlookup formulas to pull the corresponding data from the tab "DataLookup". Once the Vlookups are copied into the 3 new entries/rows (starting at K14), then we need to paste-special the values so the data is retained forever. Rows 6-13 already have the data pasted-special-value already completed and are good as-is and should not change or ever update (i.e. hard-coded and saved forever)

  8. #8
    Registered User
    Join Date
    06-20-2013
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    55

    Re: VBA assistance for copy and paste-special values into specific cells and only blank ro

    Checking to see if anyone has a way for me to accomplish what I'm trying to do here. Appreciate any help on how to code this. Thank you

+ 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] Copy data and paste special from specific rows to next empty row
    By hkbhansali in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2019, 09:55 AM
  2. Macro that copies & paste-special(Values) non-blank rows
    By Elieson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2015, 12:27 PM
  3. Replies: 2
    Last Post: 06-05-2015, 08:59 PM
  4. Copy & Paste Special Values at a Specific Time Each Day
    By srb008 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2014, 03:37 PM
  5. How to Copy and Paste Special Values Only if source Range is not blank
    By oddinho2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2013, 02:51 PM
  6. Need macro button to copy and paste special values into next available blank row
    By AngelaG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2011, 07:55 AM
  7. Copy and Paste Special Values Macro ignoring cells with specific condition
    By chendriks47 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2011, 03:01 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