Checkbox - Output results to a csv file

E

Ephraim

Hi,

I have a small spreadsheet with 20 check boxes in Column A (A1-A20).
They are all linked to corresponding cells in Column B which give TRUE
or FALSE depending on if they are checked or unchecked. No problem
there.

I have the corresponding check boxes displaying "Computer 1" in cell
C1 and so on down to C20
i.e. Formula in C1 is =IF(B1,"Computer 1","")

Once the user has checked/unchecked as required then I'd like to be
able to save Column C1:C20 and Column D1:D20 to a csv file called
"UserInput.csv"

Thanks
Ephraim
 
D

Dave Peterson

I'd start a new workbook
Then back to the original worksheet
Edit|Copy columns C:D
Edit|Pastespecial|values into A1 of the new worksheet in the new workbook

Save this file as the .csv file

Close the new workbook.

========
Another option that may work for you:

Put a formula like this in E1:
=c1&","&d1
and drag down

Then copy this column and paste into NotePad. Save that as a .CSV file.

Depending what's in those fields, you may want to add double quotes, too.
 
E

Ephraim

I'd start a new workbook
Then back to the original worksheet
Edit|Copy columns C:D
Edit|Pastespecial|values into A1 of the new worksheet in the new workbook

Save this file as the .csv file

Close the new workbook.

========
Another option that may work for you:

Put a formula like this in E1:
=c1&","&d1
and drag down

Then copy this column and paste into NotePad.  Save that as a .CSV file..

Depending what's in those fields, you may want to add double quotes, too.










--

Dave Peterson- Hide quoted text -

- Show quoted text -

I'm trying to make this as transparent to the user as possible. The
resulting file will be providing input to a powershell 2.0 script.
Leaving it to the user leaves room for error. I would like to
eliminate as much user error as possible by automating as much of this
as possible.

I've googled some lengthy examples of how to do this but was hoping
someone with more knowledge than I would be able to provide a quicker
fix for this than the 80 to 100 lines that I was able to find.

Thanks
 
D

Dave Peterson

I'd drop a button from the Forms toolbar on the worksheet and assign this macro
to the button:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim NewWks As Worksheet
Dim myPath As String
Dim myFileName As String

Set wks = ActiveSheet

myPath = "C:\"
If Right(myPath, 1) <> "\" Then
myPath = myPath & "\"
End If

myFileName = "UserInput.csv"

'the first worksheet in a single sheet workbook:
Set NewWks = Workbooks.Add(1).Worksheets(1)

wks.Range("C:d").Copy

With NewWks
.Range("A1").PasteSpecial Paste:=xlPasteValues
'avoid the prompt if the file already exists
Application.DisplayAlerts = False
.Parent.SaveAs Filename:=myPath & myFileName, FileFormat:=xlCSV
Application.DisplayAlerts = True
.Parent.Close savechanges:=False
End With

End Sub
 
E

Ephraim

I'd drop a button from the Forms toolbar on the worksheet and assign thismacro
to the button:

Option Explicit
Sub testme()

    Dim wks As Worksheet
    Dim NewWks As Worksheet
    Dim myPath As String
    Dim myFileName As String

    Set wks = ActiveSheet

    myPath = "C:\"
    If Right(myPath, 1) <> "\" Then
        myPath = myPath & "\"
    End If

    myFileName = "UserInput.csv"

    'the first worksheet in a single sheet workbook:
    Set NewWks = Workbooks.Add(1).Worksheets(1)

    wks.Range("C:d").Copy

    With NewWks
        .Range("A1").PasteSpecial Paste:=xlPasteValues
         'avoid the prompt if the file already exists
        Application.DisplayAlerts = False
        .Parent.SaveAs Filename:=myPath & myFileName, FileFormat:=xlCSV
        Application.DisplayAlerts = True
        .Parent.Close savechanges:=False
    End With

End Sub

Absolutely perfect! Exactly what I was looking for. Thank you very
much.
 

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