Solved

Embedding VBA (Excel) Variable in Strings

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

705 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

17 Experts available now in Live!

Get 1:1 Help Now