+ Reply to Thread
Results 1 to 12 of 12

VBA - Data not transferring when running macro

  1. #1
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    VBA - Data not transferring when running macro

    Hi guys,

    I'm currently running the following:

    Please Login or Register  to view this content.
    However, the data isn't transferring to the new workbook and I can't quite figure out why.

    Any help is greatly appreciated!
    Last edited by aeronaught; 06-26-2018 at 09:35 AM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Data not transferring when running macro

    Please Login or Register  to view this content.
    Using the inputbox makes the variable a string. Use the CDate function to convert the string to a date data type.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: VBA - Data not transferring when running macro

    Unfortunately, it's still not working.

    I've ran debug, and when it gets to this part of the code:
    Please Login or Register  to view this content.
    It applies the filter, but no data is selected for transfer between the date range specified.

    Any ideas?
    Last edited by aeronaught; 06-25-2018 at 10:16 AM.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Data not transferring when running macro

    That is what the CDate is for. It is not finding the value of your variable from the input box. I had the same problem when I ran a test set up. Then I used the CDate on that line of code As shown in Post #2 and it then filtered the data correctly and copied it over. Also, you are essentially filtering on the UsedRange.Offset(3) with column 15 ("O") being the key search range for the criteria to match. Make sure you have the correct column with dates in it.

  5. #5
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: VBA - Data not transferring when running macro

    Still no luck.

    As far as I'm aware, everything is in the correct column.

    I've attached a mock spreadsheet with all sensitive data redacted. Can you see where I'm perhaps going wrong?
    Attached Files Attached Files

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Data not transferring when running macro

    It could be your system default date format is the problem because when I tried runing the code on my system it automatically converted the input box dates but not the dates in column O and that resulted in the filter failing. Dates are a real pain to work with sometimes.

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: VBA - Data not transferring when running macro

    Try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: VBA - Data not transferring when running macro

    Quote Originally Posted by Fluff13 View Post
    Try
    Please Login or Register  to view this content.
    Well blow me down. It worked! Thank you my man!

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: VBA - Data not transferring when running macro

    Glad we could help & thanks for the feedback

  10. #10
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Data not transferring when running macro

    That's the trick with dates. When trying to match between different cells, they have to equate to the same value. Date data types are either long integers or doubles if time is included. But dates can also be entered as string values, so when trying to match between cells, you have to determine what each cell value equates to in terms of data types.

  11. #11
    Registered User
    Join Date
    09-10-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    8

    Re: VBA - Data not transferring when running macro

    Really appreciate your help you two! I've been at a loss for days. I can't believe it was something so simple!

    Just to piggyback off of this (is that even allowed? I can't find anything in the forum rules) - at the moment, I have to open a separate spreadsheet named "End of year" with exactly the same tab names as "FO New" for this macro to work. Is there any way to have the macro automatically generate a spreadsheet called "End of year" with all the tabs and information I'm after?
    Last edited by aeronaught; 06-26-2018 at 12:12 PM.

  12. #12
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: VBA - Data not transferring when running macro

    Please Login or Register  to view this content.
    You could use something like this which would save the existing workbook with the sheet names you want, using the workbook name you want. Then the loop will take the existing data out of the sheets, leaving bland sheets with original names, except any macros will be available if the original file was macro enabled. But all data will be gone.

+ 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. range matching and data transferring macro running slowly
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2017, 09:49 PM
  2. Transferring data using a macro
    By deano3141 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-13-2014, 09:05 AM
  3. Replies: 1
    Last Post: 02-05-2014, 03:43 PM
  4. Need a macro for transferring data based on unit value to corresponding tab
    By doubl3d80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2012, 03:45 PM
  5. Macro for transferring/copying data from one tab to another
    By AJJ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-08-2012, 02:29 PM
  6. Replies: 2
    Last Post: 06-29-2011, 03:35 AM
  7. Transferring numbers to keep a running total.
    By evenings in forum Excel General
    Replies: 1
    Last Post: 04-21-2008, 11:12 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