Solved

Embedding VBA (Excel) Variable in Strings

Posted on 2007-03-23
2
597 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

862 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now