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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,953
Messages
6,175,598
Members
452,658
Latest member
GStorm

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