Hi all!
First post on here so helloMy query is quite straightforward, I need to export data from one spreadsheet into another, new spreadsheet (which should be created when the macro is run). The idea is that each column and row will have a tick box at the top/side of them, the user will tick each column or row that the want on the other spreadsheet and when a button is clicked, the whole lot gets copied to the newly created sheet (without the links).
Is this do able? I have tried to make it work but im not very fluent in vba at all.
Attachment 136043
Thanks in advance
Storm08
Last edited by Storm08; 01-24-2012 at 08:37 AM.
Please attach the sample workbook.
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
I cant put the actually sheet on here because of confidential reasons but here's an example to give you an idea
I dont know what the best way would be to go about it, it's had me stumped for a good few days because of my limited experience with programming in vb.
Thanks for the reply![]()
Last edited by Storm08; 01-12-2012 at 10:34 AM.
So if a checkbox is clicked, which sections should be copied? For example, in your attachment, if only A3 is clicked, then should only row 3 be copied without the headers?
Cheers,
Arlette
If I helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Basically if the checkbox on a row is checked then get the macro to select it, if a column is selected as well then add the whole row to the selection, then what ever has been select will get copied when a button is clicked. Sorry if im asking a lot, i was just wondering what would be the best way to go about it was and how.
Thank you![]()
Anyone have answer for this?
Would it be possible to do this based on a cells contents. For instance, there are columns with headings at the top, above each heading there is a box that will either say T or F (True of False).
When the macro is run, each column that says "T" will be copied to a new document with all of the values that the column holds. Is this possible or not?
assuming:
- the data in sheet1
- the sheet to be copied to sheet2
- the ActiveX-checkbox for column G Checkbox7
Private Sub Checkbox7_Click() if checkbox7 then sheets("sheet2").columns(7)=sheets("sheet1").column(7).value End Sub
I don't really get what you are after, but give this a go.
It will put it onto sheet 2 in the first instance, but can be easily adapted to another workbook.
Sub test() Dim shpsRng As Collection Dim rng As Range Dim oCell As Object Dim x As Integer Set shpsRng = New Collection For x = 1 To Sheet1.Shapes.Count If Sheet1.CheckBoxes(x).Value = 1 Then shpsRng.Add Sheet1.CheckBoxes(x).TopLeftCell End If Next x With Sheet1.Cells(3, 3).CurrentRegion For x = 1 To shpsRng.Count If shpsRng(x).Row = 1 Then If Not rng Is Nothing Then Set rng = Union(rng, .Columns(shpsRng(x).Column - 1)) Else Set rng = .Columns(shpsRng(x).Column - 1) End If Else If Not rng Is Nothing Then Set rng = Union(rng, .Rows(shpsRng(x).Row - 1)) Else Set rng = .Columns(shpsRng(x).Row - 1) End If End If Next x End With For Each oCell In rng Sheet2.Range(oCell.Address) = oCell.Value Next End Sub
Last edited by Kyle123; 01-16-2012 at 10:04 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
Wow, thanks for the replies, ill give them a go and let you know![]()
Last edited by Storm08; 01-17-2012 at 07:24 AM.
UPADTE! It seems to be working very well apart from when i un-check a box, it breaks at the red code:
Otherwise it works brilliantly!Sub test() Dim shpsRng As Collection Dim rng As Range Dim oCell As Object Dim x As Integer Set shpsRng = New Collection For x = 1 To Sheet1.Shapes.Count If Sheet1.CheckBoxes(x).Value = 1 Then shpsRng.Add Sheet1.CheckBoxes(x).TopLeftCell End If Next x With Sheet1.Cells(3, 3).CurrentRegion For x = 1 To shpsRng.Count If shpsRng(x).Row = 1 Then If Not rng Is Nothing Then Set rng = Union(rng, .Columns(shpsRng(x).Column - 1)) Else Set rng = .Columns(shpsRng(x).Column - 1) End If Else If Not rng Is Nothing Then Set rng = Union(rng, .Rows(shpsRng(x).Row - 1)) Else Set rng = .Columns(shpsRng(x).Row - 1) End If End If Next x End With For Each oCell In rng Sheet2.Range(oCell.Address) = oCell.Value Next End Sub![]()
What error message do you get?
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
Try this:
Sub test() Dim shpsRng As Collection Dim rng As Range Dim oCell As Object Dim x As Integer Set shpsRng = New Collection For x = 1 To Sheet1.Shapes.Count If Sheet1.CheckBoxes(x).Value = 1 Then shpsRng.Add Sheet1.CheckBoxes(x).TopLeftCell End If Next x If shpsRng.Count <> 0 Then With Sheet1.Cells(3, 3).CurrentRegion For x = 1 To shpsRng.Count If shpsRng(x).Row = 1 Then If Not rng Is Nothing Then Set rng = Union(rng, .Columns(shpsRng(x).Column - 1)) Else Set rng = .Columns(shpsRng(x).Column - 1) End If Else If Not rng Is Nothing Then Set rng = Union(rng, .Rows(shpsRng(x).Row - 1)) Else Set rng = .Rows(shpsRng(x).Row - 1) End If End If Next x End With For Each oCell In rng Sheet2.Range(oCell.Address) = oCell.Value Next Else MsgBox "Nothing was selected" End If End Sub
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
The error message doesnt come up anymore and the message box appears when you uncheck it. Would it be possible to undo or delete the column of data when the box is unchecked?
Sorry im asking a lot, i would like to try and do it myself but im still trying to get my head round your first bit of code :P
This is a massive help so far! thank you very much!
EDIT:
Oh and also,it only copies a certain amount to the other sheet. I would have changed the range of data copied but i wasn't sure what to change.
Last edited by Storm08; 01-17-2012 at 11:49 AM.
maybe this:
Sub test() Dim shpsRng As Collection Dim rng As Range Dim oCell As Object Dim x As Integer Set shpsRng = New Collection For x = 1 To Sheet1.Shapes.Count If Sheet1.CheckBoxes(x).Value = 1 Then shpsRng.Add Sheet1.CheckBoxes(x).TopLeftCell End If Next x Sheet2.Range(Sheet1.Cells(3, 3).CurrentRegion.Address).ClearContents If shpsRng.Count <> 0 Then With Sheet1.Cells(3, 3).CurrentRegion For x = 1 To shpsRng.Count If shpsRng(x).Row = 1 Then If Not rng Is Nothing Then Set rng = Union(rng, .Columns(shpsRng(x).Column - 1)) Else Set rng = .Columns(shpsRng(x).Column - 1) End If Else If Not rng Is Nothing Then Set rng = Union(rng, .Rows(shpsRng(x).Row - 1)) Else Set rng = .Rows(shpsRng(x).Row - 1) End If End If Next x End With For Each oCell In rng Sheet2.Range(oCell.Address) = oCell.Value Next Else MsgBox "Nothing was selected" End If End Sub
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks