+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 31 to 45 of 45

Thread: Export Data based cell value

  1. #31
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Export Data based cell value

    Sub snb()
      For Each tb In sheet1.CheckBoxes
       with tb.topleftcell
         If tb = 1 Then
            If .Row = 1 Then Sheets("sheet2").Cells(1,.Column).resize(usedrange.rows.count) = usedrange.Columns(.Column).Value
            If .Column = 1 Then Sheets("sheet2").Cells(.Column,1).resize(usedrange.colums.count) = usedrange.Rows(.Row).Value
         else
            If .Row = 1 Then Sheets("sheet2").Columns(.Column).clearcontents
            If .Column = 1 Then Sheets("sheet2").Rows(.Row).clearcontents
        End If
       end with
      Next
    End Sub



  2. #32
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    Sorry about the delay, this looks like it might just work, although atm i have an error - "Object Required", that comes up here:

    Sub test()
      For Each tb In Sheet1.CheckBoxes
       With tb.TopLeftCell
         If tb = 1 Then
            If .Row = 1 Then Sheets("Sheet2").Cells(1, .Column).Resize(UsedRange.Rows.Count) = UsedRange.Columns(.Column).Value
            If .Column = 1 Then Sheets("Sheet2").Cells(.Column, 1).Resize(UsedRange.Columns.Count) = UsedRange.Rows(.Row).Value
         Else
            If .Row = 1 Then Sheets("sheet2").Columns(.Column).ClearContents
            If .Column = 1 Then Sheets("sheet2").Rows(.Row).ClearContents
        End If
       End With
      Next
    End Sub

  3. #33
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Export Data based cell value

    It means you have to analyse the code, and to debug it.



  4. #34
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    thats what i've tried to do, except i dont realy have an experience with vb :/

    EDIT: Tried editing the code but had no luck
    Last edited by Storm08; 01-19-2012 at 07:07 AM.

  5. #35
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    Dont mean to be hassle but it would be nice to get this working sometime tomorrow.

    Thanks,
    Storm08

  6. #36
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Export Data based cell value

    Stick the code in the sheet1 code rather than a module and try it - or fully qualify the UsedRange
    Last edited by Kyle123; 01-19-2012 at 11:57 AM.
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  7. #37
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    Quote Originally Posted by Kyle123 View Post
    Stick the code in the sheet1 code rather than a module and try it - or fully qualify the UsedRange
    I tried putting in into the sheet code but i dont think it liked it :p when you say qualifying the used range dyou mean this?: http://www.homeandlearn.co.uk/excel2...l2007s7p6.html

    And what would i select for the range? just one column?

  8. #38
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Export Data based cell value

    No, I mean like this:
    UsedRange.Rows etc
    Becomes
    Sheet1.UsedRange etc
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  9. #39
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    Ah okay, i get you know Sorry, trying to learn programming properly because the only stuff i have done is at college. and that's next to nothing :/

  10. #40
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Export Data based cell value

    You have to be explicit when using code in modules, you need to tell it which sheet to reference as it has no idea. When using it in the sheet object, in this example it will use the sheet that the columns are in by default.

    Whilst learning it is probably a good idea to always be explicit as it makes it easier for you to understand exactly what's going on, also in general step through the code and have the locals window open when you are learning, you get a much better insight of what is going on.

    You can also query particular bit of code in the immediate window for example:

    ?UsedRange.Address
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  11. #41
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    I try to be explicit but dont always know what im doing :P i find it helps to do it all the time unless it may cause an error. Thanks very much for the info, better than all of the college tutors! :P

  12. #42
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    EDIT: Good news, i got rows and columns working successfully interestingly, it only works up to a certain amount of rows. goes up to 283 and then doesn't copy anything. the data on the sheet finishes at row 326, so it takes out a fair chunk.

    Any ideas?

    Thanks,
    Storm08

    EDIT: Okay... dont worry, i just found a slightly strange solution... o.0

    All i did was put a thick border along the left hand side of the spreadsheet and it worked...

    how did that make a difference???
    Last edited by Storm08; 01-20-2012 at 09:26 AM.

  13. #43
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    Hey guys, The code is work very well now, just 1 problem, when the data is copied to the second sheet, the data copies fine but underneath the data, all the cells have " #N/A " in them. there's about 16000 rows of it each time. :/

    I dont know what to do, would be happy for any help

    Thank you,
    Storm08

  14. #44
    Valued Forum Contributor Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds/Sheffield, England
    MS-Off Ver
    Excel 2003
    Posts
    1,031

    Re: Export Data based cell value

    Do you have any formulas in the rows below?

    I would say (without having seen your workbook) that the first issue was caused by having a blank row in your data
    Click the * below to say thanks

    Girls sleep with guys who use photoshop, but marry the ones who work with Excel

    Corduroy
    pillows: They're making headlines!

    Did you mean: recursion
    http://www.google.com/search?hl=en&q=recursion

  15. #45
    Registered User
    Join Date
    01-12-2012
    Location
    Aylesbury
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Export Data based cell value

    That first issue is sorted now, i dont really know what it was but its gone :P and i dont have any formula in the rows below, it's completely empty.

    EDIT:Managed to sort it
    Last edited by Storm08; 01-24-2012 at 08:36 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0