+ Reply to Thread
Results 1 to 32 of 32

Last 8 columns to export to a new sheet

  1. #1
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Post Last 8 columns to export to a new sheet

    Hi,

    I have a sheet with name "new updates" in which I will update columns data daily. I want a macro which will export the first column and last 8 columns to a new workbook with name "updates_august_week3"(current month_current week in that month). The last 8 columns should be count based on row 2.

    Please help me.
    Please note that there are some hidden rows in the sheet 8 to 14

    Attached is the reference workbook.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    any help please

  3. #3
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    I Tried with the below macro but not working...any modification help please
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    any help please..

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Last 8 columns to export to a new sheet

    Just because i see your bumps for response i'd like to tell you that if you will not find any VBA solution and if you are interest we could do this using formulae.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    I am sorry. it will be helpful if you could give me a macro. if not i will try with a formula. but i dont think that it will completely helpful for me.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    In your code you need to change:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    it is working. can i have the same color formatting also to copied to the destination? yudlugar

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    Maybe:
    Please Login or Register  to view this content.

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

    Re: Last 8 columns to export to a new sheet

    Maybe:

    Please Login or Register  to view this content.
    Do you mean a new workbooks or worksheet? I created a sheet1 manually to test.

  11. #11
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    its working...just one doubt....will it copy the same way if the cells have formulas which dont reflect any value.

  12. #12
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    how do i paste them as values with color formatting yudlugar

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    I'd guess you'd have to do it separately, I don't think you can paste color formatting separate to all the other formatting though.:
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    Okay. Thanks

  15. #15
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    Need some more help..

    I have the code which is working which is posted above...

    Please Login or Register  to view this content.
    There is a small problem. I have formulas in cells which are not reflecting any value. (I mean cell has no value but formula in it).
    So, the above macro is taking the last 8 columns which has formulas also with no values.

    Can anybody modify the macro so that it should take only if values are there.

  16. #16
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    Do you want the last column with a value and the preceeding 7 columns or the last 8 columns with a value in (i.e. skip any blanks)?

  17. #17
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    I want the last 8 columns which has values only. But not formulas.

  18. #18
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    Maybe something along the lines of:
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    application defined error or object defined error is coming at line 4 in the posted macro

  20. #20
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    I put the bracket in the wrong place
    count_col = .Range(.Cells(1, Columns.Count)).End(xlToLeft).Column
    although probably can be simplified to
    .cells(1,columns.count).end(xltoleft).column

  21. #21
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    object does not support this property or method.. if i put .cells(1,columns.count).end(xltoleft).column and the same previous error if i put count_col = .Range(.Cells(1, Columns.Count)).End(xlToLeft).Column

  22. #22
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    Ok I've tested this one properly and can't find any issues:

    Please Login or Register  to view this content.

  23. #23
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    it is still copiying those columns with formulas which dont have any values

  24. #24
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    Can you define "no values"? Preferably by uploading a workbook with an example?

    Note - the macro I wrote will look in row 1 for the value, so if the header still exists but there is no data in the table it will still copy. It assumes that if the column has no values, row 1 of that column will also have no value.

    It also assumes that no value means "", not 0.

  25. #25
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    Yes, I will upload the sample again..Thanks for your help really...I changed in the macro to look in row 2.
    Attached Files Attached Files

  26. #26
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    That file has all values and no formulas. I still do not understand what you mean by "has no value". Can you upload a workbook with an example of a column that has formulas but you do not want copying.

    On your example, if I enter ="" into column S it will still copy columns K to R which I think is what you want?

  27. #27
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    In the previously attached file the new updates sheet in range from i2 to i5 has formulas. so if you run the macro it is copiying that column as well eventhough it dont have any values. I hope you got my point this time.

  28. #28
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    Sorry in S2 to S5 has formulas

  29. #29
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    There are no formulas in S2 to S5 in the new file you uploaded. When I run the macro on the new file you uploaded it does not copy column S. Please try again to upload a file with example or macro not working (e.g. formulas in column S)

  30. #30
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Post Re: Last 8 columns to export to a new sheet

    Okay...Please find the file again. I am highlighting the cells with formulas in yellow color in new updates sheet.
    Attached Files Attached Files

  31. #31
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Last 8 columns to export to a new sheet

    It didn't work because you still have the header in column S, you needed to change one of the other statements to row 2 also:
    Please Login or Register  to view this content.

  32. #32
    Forum Contributor
    Join Date
    01-17-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    402

    Re: Last 8 columns to export to a new sheet

    Okay..Got it. Thanks!! It worked for me...

+ 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. Button to export columns to a new sheet.
    By halfelite in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 03:42 PM
  2. Replies: 0
    Last Post: 02-22-2013, 09:23 AM
  3. Export Columns to New Worksheet
    By Ray789 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-26-2010, 01:09 PM
  4. Tweak two columns, then export them from CSV
    By AnotherExcelNb in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 06-13-2008, 04:16 AM
  5. export columns to a new sheet
    By lom2pac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-18-2008, 05:54 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