+ Reply to Thread
Results 1 to 4 of 4

VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS

  1. #1
    Registered User
    Join Date
    05-11-2017
    Location
    Wolverhampton, England
    MS-Off Ver
    2010
    Posts
    2

    VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS

    need some help please

    I am creating a spreadsheet which records the time spent by staff carrying out certain tasks and runs reports so that management can see how much time is spent carrying out tasks by staff member or by task.

    Sheet 1 I have tried to design as a user friendly sheet for staff to input their times, using drop down menus the user can find himself/ herself, find the task he/she has done and the manually input the time spend undertaking that work. with space in 4 rows (4-7) for up to 4 tasks to be added

    There are 4 columns for this info
    Date - cells D4-D7
    Legal Adviser - cells E4-E7
    Work Undertaken- cells F4-F7
    Time- cells G4-G7

    I have included a button in sheet 1 to copy the info in cells D4-G7 from sheet 1 to sheet 2 and then clear the data from those cells so that sheet 1 is blank again for the next user to input their data.

    The problem I have is that the code will only copy the data if all 4 rows 4-7 are completed, whereas I want the code to copy only those rows which are completed and ignore any blank ones. So for example if the legal adviser has only carried out 2 types of work that day, and therefore only filled in rows D4-G4 and D5-G5, the code will only copy those rows onto sheet 2 and will not insist that all 4 rows be completed.

    The code I currently have is:
    Please Login or Register  to view this content.

    I have fudged this through trial and error. Is there any way to tinker with this code so that it will ignore blank cells within the range of E4-G7 range?
    Any help would be greatly appreciated
    Thanks
    Last edited by alansidman; 05-14-2017 at 06:09 PM.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS

    Welcome to the forum,
    first can i ask to put code tags on your code
    select the code and select the #
    this looks better and reads better like the code down here

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-11-2017
    Location
    Wolverhampton, England
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS

    Thanks so much for this, it is just what I was after. You have saved me a great deal of time.

    Callum

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,862

    Re: VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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] help finish/fix this code: copy non-blank cells to corresponding cell on another sheet
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2016, 01:38 PM
  2. VBA: Copy non-blank and paste to separate sheet ONLY blank cells (running list)
    By brolsen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2014, 03:34 PM
  3. Replies: 5
    Last Post: 12-12-2013, 02:53 PM
  4. Copy certain info in one sheet to a new sheet to a different area and rename new sheet
    By Elmarie_Potgieter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2013, 05:34 AM
  5. [SOLVED] VBA code to copy cell values to the next blank row in another sheet (all the same row)
    By rarias in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2013, 03:08 AM
  6. [SOLVED] VB code help- need copy cells in a row and paste to new sheet on next available blank line
    By Barbara Excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-27-2012, 03:11 PM
  7. Sheet code to copy & paste a new row of Info to another sheet
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 05:31 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