Solved

Embedding VBA (Excel) Variable in Strings

Posted on 2007-03-23
2
605 Views
Last Modified: 2013-12-26
How does one go about embedding a variable, i.e. below I try  to save successive worksheets to a folder.  How do I assign the protein name in the FOR loop to the destination filename with the .txt extension below?

Dim Protein As Variant
Protein = Array("PRAF", "PMEK", "PLC", "PIP2", "PIP3", "ERK", "AKT", "PKA", "PKC", "P38", "PJNK")

For i = 0 To UBound(Protein)

    Sheets(Protein(i)).Select
    ChDir "C:\Documents and Settings\yiprobpat2003\Desktop\Thesis\Comparisons"
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\yiprobpat2003\Desktop\Thesis\Comparisons\PLC.txt", _
        FileFormat:=xlTextMSDOS, CreateBackup:=False
Next

Thanks again for the help.

Jason
0
Comment
Question by:cdromes
2 Comments
 
LVL 4

Accepted Solution

by:
g_johnson earned 50 total points
ID: 18782145
ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\yiprobpat2003\Desktop\Thesis\Comparisons\" & Protein(i) & ".txt", _
        FileFormat:=xlTextMSDOS, CreateBackup:=False
0
 

Author Comment

by:cdromes
ID: 18785046
Great!  Thanks.
0

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question