Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Date reformat and export

To all,

I have a workbook that contains many worksheets named after a date for
example 2007911(1), 2007911(2) etc. (Format - yyyyddmm)

I want to be able to run a macro that will strip all the () (brakets)
out of the dates and insert an _, i.e. turn 2007911(1) into 2007911_1
and 2007911_2 etc.

I then want to be able to copy all the sheets in this format to a
workbook called PAT.xls. and then run or call a macro named 'test'
which is in a module in PAT.xls. I have a worksheet called control
which I do not wish to copy over to PAT.xls.

Is there an easy way to do this?

Thanks


Thanks in advance for your help,

Regards

Joseph Crabtree
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Date reformat and export


Sub fixsheetname()

For Each sht In ActiveWorkbook.Sheets
If InStr(sht.Name, "(") 0 Then
bracketpos = InStr(sht.Name, "(")
prefixname = Trim(Left(sht.Name, bracketpos - 1))
shtnumber = Trim(Mid(sht.Name, bracketpos + 1))
shtnumber = Trim(Left(shtnumber, InStr(shtnumber, ")") - 1))
sht.Name = prefixname & "_" & shtnumber
End If
Next sht
End Sub

"joecrabtree" wrote:

To all,

I have a workbook that contains many worksheets named after a date for
example 2007911(1), 2007911(2) etc. (Format - yyyyddmm)

I want to be able to run a macro that will strip all the () (brakets)
out of the dates and insert an _, i.e. turn 2007911(1) into 2007911_1
and 2007911_2 etc.

I then want to be able to copy all the sheets in this format to a
workbook called PAT.xls. and then run or call a macro named 'test'
which is in a module in PAT.xls. I have a worksheet called control
which I do not wish to copy over to PAT.xls.

Is there an easy way to do this?

Thanks


Thanks in advance for your help,

Regards

Joseph Crabtree

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Date reformat and export

I added to the code the COPY request. the code assumes the workbook PAT.XLS
is opend

Sub fixsheetname()

For Each sht In ActiveWorkbook.Sheets
If InStr(sht.Name, "(") 0 Then
bracketpos = InStr(sht.Name, "(")
prefixname = Trim(Left(sht.Name, bracketpos - 1))
shtnumber = Trim(Mid(sht.Name, bracketpos + 1))
shtnumber = Trim(Left(shtnumber, InStr(shtnumber, ")") - 1))
sht.Name = prefixname & "_" & shtnumber

With Workbooks("Pat.xls")
sht.Copy after:=.Sheets(.Sheets.Count)
End With
End If
Next sht
End Sub

"Joel" wrote:


Sub fixsheetname()

For Each sht In ActiveWorkbook.Sheets
If InStr(sht.Name, "(") 0 Then
bracketpos = InStr(sht.Name, "(")
prefixname = Trim(Left(sht.Name, bracketpos - 1))
shtnumber = Trim(Mid(sht.Name, bracketpos + 1))
shtnumber = Trim(Left(shtnumber, InStr(shtnumber, ")") - 1))
sht.Name = prefixname & "_" & shtnumber
End If
Next sht
End Sub

"joecrabtree" wrote:

To all,

I have a workbook that contains many worksheets named after a date for
example 2007911(1), 2007911(2) etc. (Format - yyyyddmm)

I want to be able to run a macro that will strip all the () (brakets)
out of the dates and insert an _, i.e. turn 2007911(1) into 2007911_1
and 2007911_2 etc.

I then want to be able to copy all the sheets in this format to a
workbook called PAT.xls. and then run or call a macro named 'test'
which is in a module in PAT.xls. I have a worksheet called control
which I do not wish to copy over to PAT.xls.

Is there an easy way to do this?

Thanks


Thanks in advance for your help,

Regards

Joseph Crabtree

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reformat a date imported from another program Heather Excel Worksheet Functions 3 November 13th 08 07:09 PM
How do I reformat a 6-digit date to general & look the same? jean Excel Discussion (Misc queries) 0 September 12th 08 03:35 AM
Copy pasting and reformat Date whatzzup Excel Discussion (Misc queries) 2 April 28th 08 08:45 PM
reformat cells for date Wackyracer Excel Discussion (Misc queries) 12 April 3rd 08 12:42 AM
To reformat a culculated date/time round-up to the nearest ½ hour Macgyver Goh Excel Programming 2 August 29th 04 03:23 PM


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"