Need help with Workbook names

  • Thread starter Thread starter Legacy 247310
  • Start date Start date
L

Legacy 247310

Guest
Hey,
In advance.... Thank you so much!!

I have two file types that have been opened in excel as 2 separate workbooks. file type 1 = .tss and file type 2 = .ptr
these file types are paired with identical file names, e.g 123.tss xls and 123.ptr xls, 456.tss xls and 456.ptr xls,789.tss xls and 789.ptr xls.

Rather than writing a macro for each pair. I am trying to write one that will use the file type before conversion .e.g .tss and .ptr without the numbers, and xls.

The reason for this is that there are several items in the ptr file that need to be formatted and placed in the tss file to be saved under as a txt file that contains the file name number (123.ptr + 123.tss = 123.txt)

is it possible to create a generic macro that will carry out the same commands over and over again from the ptr files to the tss files regardless of file name number (123)? If it is possible, may you please help me develop the macro?

:biggrin:Tulip
 
Last edited by a moderator:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi,

You can find all ptr files using the Dir() command (remeber: only specify the wildcard "*.ptr" to the first call).
Loop untill it returns an empty string (just a ptrname=Dir() inside the loop!).
From the ptr name you can find the other names using the replace function: tssname=replace(ptrname,"ptr","tss")
Inside the loop call your code with the names found or created.

Does this help you on your way?
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,593
Members
452,654
Latest member
mememe101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top