Adding data from another sheet.

B

bdunk

I hope I can find some help on this one. I have a spreadsheet that
consists of two sheets. The first is a form. The second is a list of
questions. I have added a checkbox next to each question on sheet 2 to
select the question and add it to the form on sheet 1. The problem:
when you select a question on sheet 2 it will only add it to a specific
cell on sheet 1. So if I select question 15 it will go in a position
like it is the 15th question when actually I would like it to be the
first question. The question: Is there a way to make the questions
start adding to the top cell on sheet 1 regardless of which question I
have selected on sheet 2 and also continue to add questions below the
previous question on down the sheet?

Thanks for taking a look

Bdunk
 
D

Dave Peterson

First, I used checkboxes from the Forms toolbar on my sheet2. I put them in
column A. I'd grab the questions from column B of the same row as the checkbox.

I'd also stick a button from the Forms toolbar on that same sheet. Assign it to
this macro:

Option Explicit
Sub testme()
Dim myCBX As CheckBox
Dim oRow As Long
Dim wksCBX As Worksheet
Dim wksList As Worksheet

Set wksCBX = Worksheets("sheet2")
Set wksList = Worksheets("sheet1")

oRow = 1 'top row

With wksCBX
For Each myCBX In .CheckBoxes
If myCBX.Value = xlOn Then
wksList.Cells(oRow, "A").Value _
= .Cells(myCBX.TopLeftCell.Row, "b").Value
myCBX.Value = xlOff
oRow = oRow + 1
End If
Next myCBX
End With

End Sub


It goes through the checkboxes and if it's checked it plops the value in the
adjacent cell into sheet1 (starting with Row 1.

And it clears the checkbox, too.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top