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
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
It means you have to analyse the code, and to debug it.
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.
Dont mean to be hassle but it would be nice to get this working sometime tomorrow.
Thanks,
Storm08
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
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?
No, I mean like this:
BecomesUsedRange.Rows etc
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
Ah okay, i get you knowSorry, trying to learn programming properly because the only stuff i have done is at college. and that's next to nothing :/
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
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
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.
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
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
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks